PHP MongoDB $gt Filter Operator with findOne function



我一直有困难与MongoDB操作使用PHP库。

$data =">1";                     
$val = substr($data ,1);
$filter = ["column_name" => ['$gt' => $val]];   
$test = new MongoDBDriverQuery($filter);              
$result = $collection->findOne($test);
//Echo return null value. No data from db

打印$result变量

我在运行查询时没有得到结果。请帮助。基本上我只需要知道如何传递$gt与findOne函数。

我已经找到了传递过滤器的解决方案。我修改了代码

$data =">1";                     
$val = substr($data ,1);
$filter = ["column_name" => ['$gt' => $val]];                
$result = $collection->findOne($filter);

基本上,我已经删除了"新的MongoDBBSON查询"。并直接将过滤器传递给findOne

最新更新