我尝试使用复杂的过滤器通过PHP 7在MongoDB集合中executeQuery
:
filters:wp\Database\MongoDB\Filter\Filter:private] => Array
(
[$or] => Array
(
[0] => Array
(
[generic_name] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
[1] => Array
(
[generic_name_fr] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
[2] => Array
(
[product_name] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
[3] => Array
(
[_keywords] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
[4] => Array
(
[brands] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
[5] => Array
(
[categories] => MongoDB\BSON\Regex Object
(
[pattern] => /^pain$/i
[flags] => i
)
)
)
)
但是当我运行查询时,MongoDB返回集合中的所有文档,意味着过滤器不理解。
// this->queryArray is the array that contains the filter
$query = new \MongoDB\Driver\Query($this->queryArray, []);
executeQuery
调用:
$this->cursor = $currentConnection->executeQuery("mymongodb.mycollection, $query);
之后,$this->cursor
包含集合中的所有文档,而不是包含(或以RegEx
开头的文档。
不要理解我做错了什么。
此致