我使用此查询将 NULL 值查询为“0”:
select * from myTable where IFNULL(field_id, 0) = 0
如何使用 PHP 在 MongoDB 中实现相同的功能?
我的代码:
/**
* @var MongoDB
*/
$db = $this->getMongoDbHandler();
/**
* @var MongoCollection
*/
$coll = $db->selectCollection('myColl');
/**
* @var MongoCursor
*/
$cursor = $coll->find($where);
我应该如何形成$where
数组?
我想我应该这样做:
$where['field_id'] = [
'$ifNull' => ['field_id', 0]
];
但是我在哪里指示所需的值?
谢谢!