PHP Mongo查询NOT NULL

Mic*_*rey 11 php mongodb

有人知道编写php-mongo查询的语法NOT NULL吗?

当我查询时,我知道如何执行此操作NULL:

<?php
$cursor = $collection->find(array("someField" => null));
Run Code Online (Sandbox Code Playgroud)

这甚至可能吗?

jjm*_*jjm 17

是的,你想要$ne操作员,所以

$cursor = $collection->find(array("someField" => array('$ne' => null)));
Run Code Online (Sandbox Code Playgroud)

  • @jim应该是单引号,因为`$`. (3认同)