Home:ALL Converter>PHP MongoDB Driver Query using an Array

PHP MongoDB Driver Query using an Array

Ask Time:2018-06-29T04:10:49         Author:Adam Bray

Json Formatter

I am trying to build a query in my PHP application against a MongoDB and want to check if there are any records that match an array of email addresses. The record has a nested object in it as well, so I am not 100% sure the right syntax and if it's even possible to do it this way. Appreciate any help and advice.

Nest Object:

Owner => Email

Code:

$emails = array ('[email protected]', '[email protected]', '[email protected]');

$query = new MongoDB\Driver\Query([ "Owner" => [ 'Email' => $emails ]);

Author:Adam Bray,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51090572/php-mongodb-driver-query-using-an-array
yy