both from the array:
$g = array("Drama", "Crime");
do:
$genre = array("genre" => "Drama", "genre" => "Crime");
We need to do a query to the database mongoDB, essentially with this condition:
genre = 'Drama' OR genre = 'Crime'
Here’s why I tried:
find(array("genre" => "Drama", "genre" => "Crime"))
Due to the fact that the keys are the same, it is impossible to create such an array. How can I perform the desired query?
UPD
The right solution:
$g = array("Drama", "Crime");
find(array("genre" => array('$in' => $g)))
I don’t know much about MongoDB (I had to Google this: Docs), but there is an
$inoperator. You wantgenere IN ("Drama", "Crime")I think this is how you do it in PHP/MongoDB