I have a table with some user email address like:
johndoe@somemail.com
test@test_mail.com
test2@test_mail.com
admin@company_mail.com
janedoe@someothermail.com
sales@company_mail.com
mruser@validmail.com
I want to get the user list with emails not ending with @test_mail.com OR @company_mail.com. I succeeded this with following mongo query:
db.users.find({
userEmail: {
$nin: [/@test_mail.com$/,/@company_mail.com$/]
}
})
I trid to run the same query in PHP with following code but couldn't make it work:
$criteria = array(
"userEmail" => array(
'$nin' => array(
'$regex' => new \MongoRegex("/@test_mail.com|@company_mail.com/i")
)
)
);
$cursor = $collection->find($criteria);
Any suggestions?