note 111606 added to class.mongoconnectionexception
| From: | jefffan24+phpcomment at gmail dot com | Date: | Thu, 07 Mar 2013 16:31:04 +0000 |
| Subject: | note 111606 added to class.mongoconnectionexception | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193980@lists.php.net to get a copy of this message | ||
If you have MongoClient class available and use persist option you will have a bad time and get a
MongoConnectionException
For example if you have:
<?php
$options = array(
'replicaSet' => false,
'persist' => false,
'connect' => false
);
return new \Mongo('mongodb://...', $options);
?>
This will not work if you have the mongo client class a better way to handle this if your not sure
what is on the server this code is running on is the following:
<?php
$options = array(
'replicaSet' => false,
'connect' => false
);
if(!class_exists('MongoClient')){
$options['persist'] = false;
}
return new \Mongo('mongodb:/...', $options);
?>
This will only add it in the case where MongoClient doesn't exist and it needs it. Hope this
saves anyone some heart ache.
----
Server IP: 69.147.83.199
Probable Submitter: 50.74.128.226
----
Manual Page -- http://php.net/manual/en/class.mongoconnectionexception.php
Edit -- https://master.php.net/note/edit/111606
Del: integrated -- https://master.php.net/note/delete/111606/integrated
Del: useless -- https://master.php.net/note/delete/111606/useless
Del: bad code -- https://master.php.net/note/delete/111606/bad+code
Del: spam -- https://master.php.net/note/delete/111606/spam
Del: non-english -- https://master.php.net/note/delete/111606/non-english
Del: in docs -- https://master.php.net/note/delete/111606/in+docs
Del: other reasons-- https://master.php.net/note/delete/111606
Reject -- https://master.php.net/note/reject/111606
Search -- https://master.php.net/manage/user-notes.php