From: Michael M Slusarz Date: Thu, 20 May 2010 17:02:44 +0000 (-0600) Subject: Don't run connect() if we already have active connection X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4d640aaffb98067bcba8ece0b28bfb916afb2565;p=horde.git Don't run connect() if we already have active connection --- diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php index ccaece8bd..cba44d165 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php @@ -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'])) { diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php index 616998235..bd57ba29a 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php +++ b/framework/Db/lib/Horde/Db/Adapter/Pdo/Base.php @@ -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'); } diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php index 5a260a7a8..256b98092 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php +++ b/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php @@ -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); diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php index 32e669a03..07779bed1 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php +++ b/framework/Db/lib/Horde/Db/Adapter/Pdo/Pgsql.php @@ -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'"); diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Sqlite.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Sqlite.php index 4276b1806..d86422be5 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Sqlite.php +++ b/framework/Db/lib/Horde/Db/Adapter/Pdo/Sqlite.php @@ -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);