以下过滤器['labels' => [ '$elemMatch' => new \MongoDB\BSON\Regex( '/^' . preg_quote($this->_keywords[$i]) . '$/i' )]]应用于下面的函数public static function readDB( $collectionName, $filter, $options) { //logError("readDB filter:", $filter); try { $manager = new MongoDB\Driver\Manager( "mongodb://localhost:27017" ); $rqt = new MongoDB\Driver\Query( $filter, $options ); $results = $manager->executeQuery( "leibnizdream." . $collectionName, $rqt ); return PhysicalAccessors::objectToArray( $results ); } catch (Exception $e) { logError($e->getMessage()); return array( "error" => self::MSG_KO . $collectionName ); }}结果出现以下错误:$elemMatch needs an Object我的日志报告了这一点:[$elemMatch] => MongoDB\BSON\Regex Object( [pattern] => /^ad$/i [flags] => )有人知道正确的语法吗?我没能在互联网上找到它。
添加回答
举报
0/150
提交
取消