How to get all _ids from MongoDB collection in PHP? -


i want _ids mongodb collection using php. possible?

yes, is:

$connection = new mongoclient(); $collection = $connection->database->collectionname;  $cursor = $collection->find(); foreach ( $cursor $id => $value ) {     var_dump($value['_id']); //object(mongoid) } 

you can read more mongoid object here

from comments:

if need actual id string, , try usual way, php whine because starts dollar sign , thinks it's variable. instead, use notation:

$mongoid->{'$id'} //get $id property of mongoid object 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -