我正在尝试使用MongoDB的PHP驱动程序,使用$or
运算符进行查询,但是出现了以下错误:
Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionException: $or
must be an array in /path/to/file.php:83 Stack trace: #0 /path/to/file.php(83):
MongoDB\Driver\Manager->executeQuery('userAccou...',
Object(MongoDB\Driver\Query)) #1 {main} thrown in /path/to/file.php on line 83
这是我的代码:
postSub = $_POST['register']['subdomain'];
$postEmail = $_POST['register']['email'];
$filter = ['$or' => ['subdomain' => $postSub, 'email' => $postEmail]];
$query = new MongoDB\Driver\Query($filter);
$cursor = $mongo->executeQuery('DB_Name.Collection_Name', $query);