MENU

php 操作mongo 部分技巧

June 16, 2020 • 已被 351 位童鞋围观过 • 代码分享,Mongo

一个值对应多个字段查询 or and

        $sql=array(
            '$or'=>array(
                ["title"=>['$regex' => $keyword]],
                ["title_tw"=>['$regex' => $keyword]],
            ),

           "status"=>1,"type" =>['$in' => $types]
        );

$or 必须为一个数组才可以

查询某个字段值不为空 查询某个字段值不为空

        $sql=array(
           "img" =>['$exists' => 1]
        );
Last Modified: September 28, 2023