Is it possible to make the Mongo PHP browser throw exceptions, for example PDO PDO :: ERRMODE_EXEPTION?

I prefer that my programs fail early and fail if I neglect error checking for something. Unfortunately, the Mongo extension requires me to constantly check MongoDb->lastError(). Is there an easy way to imitate array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXEPTION)using Mongo?

Preferably something that is not related to writing shell classes for everything that I would prefer to do only if I absolutely need it.

+3
source share
2 answers

No, this is currently not possible. Please write a request for the function http://jira.mongodb.org for this.

+3
source

, MongoDb->lastError()

, , .

MongoDB " ". (), , (). .

, "" . lastError(), .

:

$collection->insert(array("x" => 1), array("safe" => true));

, - . , array('safe' => true) .

-, ...

, , . "" - . "" . , , "fsync" "". , , , "w".

, Replica Sets ( 10gen ), , . , , .

, , , - - - , .

+4

All Articles