How to code MongoDB foreach Query in PHP ?
Now i have to code the same MONGODB QUERY in PHP with iterator_to_array, i don't know how to get this query to execute in PHP.
Now i stucked in this. i have given my data with some example.
USED MONGO QUERY:
db.getCollection('DRUM').find({'CODE': 'XXYYZZYY'}).forEach(
function(doc)
{
print(doc.COLLECTION.DAY);
});
Actual DB RECORD:
{
"CODE" : "XXYYZZYY",
"COLLECTION" : {
"DAY" : {
"2017-06-05" : {
"id" : 565455
},
"2017-06-15" : {
"id" : 565445
}
},
"MONTHLY" : {
"2017-06-01" : {
"id" : 564444
},
"2017-05-01" : {
"id" : 565455
}
}
},
"success" : true
}
EXPECTED OUTPUT:
{
"CODE" : "XXYYZZYY",
"COLLECTION" : {
"DAY" : {
"2017-06-05" : {
"id" : 565455
},
"2017-06-15" : {
"id" : 565445
}
}
},
"success" : true
}