I have a classroom collection structured as
{
"_id" : ObjectId("517a54a69de5ee980b000003"),
"class_name" : "A",
"students" : [{
"sname" : "John",
"age" : "13"
}, {
"sname" : "Marry",
"age" : "12"
}, {
"sname" : "Gora",
"age" : "12"
}]
}
With php, I like to get and list all students based on class _id . How can we do it?
UPDATE The query I use:
$student_list=$collection->find(array(" rid"=>new MongoId($theObjId )),
array(
"students" => 1,
)
);
I want to print it out all the list of the students. I could not manage it by using Foreach loop.