Mongodb和PHP$以及查询


Mongodb and PHP $and query

以下查询在PHP中对我不起作用,我需要帮助找出它的错误,我已经检查了其他示例,但仍然不知道如何修复它…

$query = array(
    "Client"        => $notificationJob['Client'],
    "Email"         => $notificationJob['Email'],
    "Backup Type"   => $notificationJob['Backup Type'],
    array ( "$and"  => 
        array(
            array( "Message Subject" => new MongoRegex('/'. preg_quote($notificationJob['MessageSubject string1']). '/i') ),
            array( "Message Subject" => new MongoRegex('/'. preg_quote($notificationJob['MessageSubject string2']). '/i') )
        )
    ),
    "Time Stamp"    => array('$lte'=>New Mongodate($startDate->getTimestamp()))
);

我得到的错误是:

注意:未定义的变量:and in。。。

非常感谢

使用'$and'。插入双引号中的变量。

您也可以使用"'$and"