如何mongo检查MongoDB \ Driver \ Query的Mongo文档中是否存在密钥?

时间:2018-04-26 12:20:01

标签: mongodb php-7

这个新的 MongoDB \ Driver \ Query 和MongoClient不能与php7.0一起使用的文档非常少

示例代码 -

$filter = array('$and'=> array( 
  array('code' => (string)$data[0]), 
    array('common_apps' => array($v_app => array('$exists'=>true))
)));

完整代码 -

$filter = array('$and'=> array( 
array('code' => (string)$data[0]), 
array('common_apps' => array($v_app => array('$exists'=>true))
)));

$options = array();
$query = new MongoDB\Driver\Query($filter, $options); 
$cursor = $m->executeQuery("$dbname.$collection_name", $query);

Mongo集合如下 -

  

{       “_id”:“5ae1bcb793c22d7edf76aed3”,       “代码”:“30”,       “common_apps”:[           {               “com_jio_jioplay_tv”:2           }]    }    {       “_id”:“5ae1bcb793c22d7edf76aed7”,       “代码”:“30”    }

0 个答案:

没有答案