i'm trying, to figure out how can i make this query work in mongodb.
This is the query i'm trying to do ( "translated" to mysql )
SELECT title FROM artists WHERE name LIKE "%a%" AND id NOT IN(1, 2)
The try in mongoDB
$term = new MongoRegex('/^a/i')l;
$not = array('$nin' => array('_id' => array('1', '2')));
$artists->find(array('name' => $term), $not);
$artists->find(array('name' => $term, $not))
; how can i make this work as expected, right now it returns null
Here is a solution for mongodb
db.artists.find({
"name" : /a/,
"id" : {
"$nin" : [1,2]
}
})
just by writing each {} as an array, you will get the answer for php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.