need to query MongoDB using php
- by Mario Villarroel
I need to query mongodb with something like this:
("something" < X OR "something" = "nll")
AND
("someother"X OR "someother"= "nll") AND z=$z AND s=1
I've tried a few things, but can't get it to work, this is what I've tried:
find(
array(
'$or'=array(array("something"=array("$le",$X)),array("something"="nll")),
'$or'=array(array("someother"=array("$ge",$X)),array("someother"="nll"))
))
But that's getting me the OR overwritten, so I'm lost on that...
After diggin a bit more, I assembled this code that seems to be what I need, but doesn't work either:
find( array('$and'=array( array( '$or' = array( array("something"=array('$gte'=$X)),array("something"="nll"))), array('$or' = array( array("someother"=array('$lte'=$X)),array("someother"="nll")))),"Z"=$z, "s"="1");
But this doesn't work as it returns zero results and I know for sure that there are more than 2 items that match on the db. (100% certain)