I've been having difficulty with the $and operator and MongoRegex.
I'm doing a regex record search for "Amazon" that also has the field "enabled" set to 1.
This is my query.
$search = "Amazon";
$results = $collection->find(array(
'$and' => array(
array('orgname' => new MongoRegex("/.*$search.*/")),
array('enabled' => '1')
)
));
Maybe someone can point out what I'm doing wrong. Thanks in Advance.
new MongoRegex("/.*$search.*/"). But I cannot go back and see your orignal post... Anyway, in this case you don't need the$andoperator, see my anwer.