I am adding documents to a MongoDB using PHP.
I have verified the documents have added successfully by using RockMongo.
However, When I run the find() command, it returns an empty array
$insert = $collection->insert($document);
$cursor = $collection->find();
The insert will insert the document, but find() returns “MongoCursor Object ( )”
Is there a command I need to run after the insert in order for the item to be available to find?
as taken from the documentation: find returns a pointer to the resource and you must iterate over the results to actually see the results. (just like mysql(i))
http://php.net/manual/en/mongocollection.find.php
So if you foreach over your results, it’ll work fine!