PHP+MongoDB: Uncaught exception 'MongoCursorException' with message 'No such file or directory'
Check the error code $e->getCode(); using:
try { User::$_users_collection->update($query, array('$set' => $data), $options); } catch (MongoCursorException $e) { echo "error message: ".$e->getMessage()."\n"; echo "error code: ".$e->getCode()."\n"; }
And than with the error code check the list of Mongo Cursor exception errors: http://www.php.net/manual/pt_BR/class.mongocursorexception.php
For example if you got error code 3 "This may indicate you are out of RAM or some other extraordinary circumstance.".
note: avoid the use of safe option, is deprecated. Use the WriteConcern w option, will provite more option too.
About the error:"Caused by accessing a cursor incorrectly or a error receiving a reply.Any operation that sends information to the database and waits for a response can throw a MongoCursorException. The only exception is new MongoClient() (creating a new connection), which will only throw MongoConnectionExceptions." (http://php.net/manual/en/class.mongocursorexception.php)
Mongo DB library ot be installed in PHP.ini
For Window
http://www.php.net/manual/en/mongo.installation.php#mongo.installation.windowshttps://s3.amazonaws.com/drivers.mongodb.org/php/index.html
For Linux
http://www.php.net/manual/en/mongo.installation.php#mongo.installation.nix
This help me to run mongodb via PHP