Skip to content
Advertisement

How to get object id from array using php mongod

I have a array $document after query findOne()

JavaScript

I want get 60d2f531a5476f4eb220402b by use $document['_id']->__toString(); but it never work

Advertisement

Answer

The stdClass object does not have any methods by default, so you address the $id field like this

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement