Reputation: 3290
i am having difficulty to convert mongodb shell command to php. In shell i am using
db.files.find({"username":"username",
$and:[
{'filetype': {$not : /image/}},
{'filetype':{$not:/application/}},
{'filetype':{$not:/video/}}
]
})
As you can see i am having diffculty to convert it to php. I tried few way on stack overflow but got empty result. Can anyone help on this code.
Upvotes: 0
Views: 146
Reputation: 36244
It should be
$db->files->find(array(
'username' => 'username',
'$and' => array(
array('filetype' => array('$not' => new MongoRegex('/image/'))),
array('filetype' => array('$not' => new MongoRegex('/application/'))),
array('filetype' => array('$not' => new MongoRegex('/video/'))),
),
));
BTW you could use this tiny script, to convert JSON representations to PHP:
var_export(json_decode($jsonAsString, true));
Upvotes: 1