note 105436 added to mongo.connecting

From: Date: Thu, 18 Aug 2011 02:20:43 +0000
Subject: note 105436 added to mongo.connecting
Groups: php.notes 
Request: Send a blank email to php-notes+get-182552@lists.php.net to get a copy of this message
Hello, Which one of the below options (or coding style) is best for a production environment to work properly: // Option 1: recreate connection per page $m = new Mongo("mongodb://$user:$pwd@$srvr/$db"); // Option 2: recreate connection per session but reuse within web session $_SESSION["m"] = new Mongo("mongodb://$user:$pwd@$srvr/$db"); // Option 3: create connection once and reuse with web server (across all web sessions) $_SERVER["m"] = new Mongo("mongodb://$user:$pwd@$srvr/$db"); I have read read a lot and bounced back and forth between MongoDB and PHP web sites but it is still unclear to me what approach is best? Thanks and Happy Coding! ---- Server IP: 69.147.83.197 Probable Submitter: 148.87.19.214 ---- Manual Page -- http://www.php.net/manual/en/mongo.connecting.php Edit -- https://master.php.net/note/edit/105436 Del: integrated -- https://master.php.net/note/delete/105436/integrated Del: useless -- https://master.php.net/note/delete/105436/useless Del: bad code -- https://master.php.net/note/delete/105436/bad+code Del: spam -- https://master.php.net/note/delete/105436/spam Del: non-english -- https://master.php.net/note/delete/105436/non-english Del: in docs -- https://master.php.net/note/delete/105436/in+docs Del: other reasons-- https://master.php.net/note/delete/105436 Reject -- https://master.php.net/note/reject/105436 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182552) next »