Don't run connect() if we already have active connection
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 May 2010 17:02:44 +0000 (11:02 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 May 2010 17:06:57 +0000 (11:06 -0600)
framework/Db/lib/Horde/Db/Adapter/Mysqli.php
framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php
framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php
framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php
framework/Db/lib/Horde/Db/Adapter/Pdo/Sqlite.php

index ccaece8..cba44d1 100644 (file)
@@ -112,6 +112,10 @@ class Horde_Db_Adapter_Mysqli extends Horde_Db_Adapter_Base
      */
     public function connect()
     {
+        if ($this->_active) {
+            return;
+        }
+
         $config = $this->_parseConfig();
 
         if (!empty($config['ssl'])) {
index 6169982..bd57ba2 100644 (file)
@@ -32,6 +32,10 @@ abstract class Horde_Db_Adapter_Pdo_Base extends Horde_Db_Adapter_Base
      */
     public function connect()
     {
+        if ($this->_active) {
+            return;
+        }
+
         list($dsn, $user, $pass) = $this->_parseConfig();
 
         $oldErrorReporting = error_reporting(0);
@@ -59,7 +63,8 @@ abstract class Horde_Db_Adapter_Pdo_Base extends Horde_Db_Adapter_Base
      */
     public function isActive()
     {
-       return isset($this->_connection) && $this->_connection->query('SELECT 1');
+        return isset($this->_connection) &&
+               $this->_connection->query('SELECT 1');
     }
 
 
index 5a260a7..256b980 100644 (file)
@@ -56,6 +56,10 @@ class Horde_Db_Adapter_Pdo_Mysql extends Horde_Db_Adapter_Pdo_Base
      */
     public function connect()
     {
+        if ($this->_active) {
+            return;
+        }
+
         parent::connect();
 
         // ? $this->_connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
index 32e669a..07779be 100644 (file)
@@ -75,10 +75,16 @@ class Horde_Db_Adapter_Pdo_Pgsql extends Horde_Db_Adapter_Pdo_Base
     ##########################################################################*/
 
     /**
-     * Connect to the db
+     * Connect to the db.
+     *
+     * @throws Horde_Db_Exception
      */
     public function connect()
     {
+        if ($this->_active) {
+            return;
+        }
+
         parent::connect();
 
         $retval = $this->_connection->exec("SET datestyle TO 'iso'");
index 4276b18..d86422b 100644 (file)
@@ -74,10 +74,16 @@ class Horde_Db_Adapter_Pdo_Sqlite extends Horde_Db_Adapter_Pdo_Base
     ##########################################################################*/
 
     /**
-     * Connect to the db
+     * Connect to the db.
+     *
+     * @throws Horde_Db_Exception
      */
     public function connect()
     {
+        if ($this->_active) {
+            return;
+        }
+
         parent::connect();
 
         $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);