I have a query like this
db.listings.find({ "h_id": ObjectId("52f1fb19388f5827148b4567"), "data.status":1,"data.startdate":new Date("2014-03-10"),"data.enddate":new Date("2014-03-12") }, {"data.$":1 });
Which will return the sub documents which has startdate= 2014-03-10 and enddate 2014-03-12.
Bu when I try to code the same in php-mongo, the array is empty.
I have tried like this
$query = array("h_id" => new MongoId($hId),
"data.status" => 1,
"data.startdate" => new MongoDate(strtotime("2014-03-10")),
"data.enddate" => new MongoDate(strtotime("2014-03-12")));
$projection = array("data.$" => true);
$cursor = $collection->find($query, $projection);
Is it possible to check the dates direcly in php-mongo or do we need to use '$lte' or '$gte' for checking dateranges.
Can anyone please help me to fix this?
Thanks