i am new on php and mongodb. i want to find all data which match the condition in php. the following mongodb structure:
'Food' =>
array (size=4)
'_id' =>
object(MongoId)[36]
public '$id' => string '587e4a89974711036c97d3e5' (length=24)
'CaseId' => string 'c002' (length=4)
'Level' => string '4' (length=1)
'food' => string 'banana' (length=6)
i try to search 'food' value in Food object. i have do some research. i have some method to deal with. however, i cannot find anything. i don't know where wrong? hope someone can teach me. here is my query:
$cursor=$collection->find(array("Food.food"=>array('$in'=>["banana"])));
$cursor=$collection->find(array('Food'=>array('food'=>"banana")));
$cursor=$collection->find(array('Food.food'=>"banana"));
after i research, i know MongoDB supports dot notation. resource from enter link description here also i find some get nested field method from enter link description here i following the link 2 to typing in mongodb compass. i can get the result i want, but when i follow the structure to enter in php. it have not any result. what happen in these code?? i am confused. thank you.