From 71f0099cf443eaa98e2510b3fc274da4715b3b36 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 13 Nov 2014 15:16:09 +0200 Subject: Fix an issue with 'postgre' persistent connections Basically, they were never persistent. --- system/database/drivers/postgre/postgre_driver.php | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'system/database/drivers/postgre') diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index bdb8a7127..18a218104 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -149,22 +149,21 @@ class CI_DB_postgre_driver extends CI_DB { */ public function db_connect($persistent = FALSE) { - if ($persistent === TRUE - && ($this->conn_id = pg_pconnect($this->dsn)) - && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD - && pg_ping($this->conn_id) === FALSE - ) - { - return FALSE; - } - else - { - $this->conn_id = pg_connect($this->dsn); - } + $this->conn_id = ($persistent === TRUE) + ? pg_pconnect($this->dsn) + : pg_connect($this->dsn); - if ($this->conn_id && ! empty($this->schema)) + if ($this->conn_id !== FALSE) { - $this->simple_query('SET search_path TO '.$this->schema.',public'); + if ($persistent === TRUE + && pg_connection_status($this->conn_id) === PGSQL_CONNECTION_BAD + && pg_ping($this->conn_id) === FALSE + ) + { + return FALSE; + } + + empty($this->schema) OR $this->simple_query('SET search_path TO '.$this->schema.',public'); } return $this->conn_id; -- cgit v1.2.3-24-g4f1b