diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:52:16 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:52:16 +0100 |
commit | 8335a5db2a44b9272b066f524223b58904dd9f3f (patch) | |
tree | 688f1f0115c33bc65f40c5600e02f20b64d65537 /system/database/drivers/postgre | |
parent | 718d9ef22c4663f59f6f43c8945944f1f165c800 (diff) | |
parent | 8e89df8f92444eb02dc73b6c3e66077a4fb3f710 (diff) |
Merge upstream branch
Diffstat (limited to 'system/database/drivers/postgre')
-rw-r--r-- | system/database/drivers/postgre/postgre_driver.php | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 4e77b9f1c..ce5dc96c3 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -200,34 +200,30 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Database version - * - * This method overrides the one from the base class, as if PHP was - * compiled with PostgreSQL version >= 7.4 libraries, we have a native - * function to get the server's version. + * Database version number * * @return string */ public function version() { - $version = pg_version($this->conn_id); - - /* If we don't have the server version string - fall back to - * the base driver class' method - */ - return isset($version['server']) ? $version['server'] : parent::version(); - } + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } - // -------------------------------------------------------------------- + if (($pg_version = pg_version($this->conn_id)) === FALSE) + { + return FALSE; + } - /** - * Version number query string - * - * @return string - */ - protected function _version() - { - return 'SELECT version() AS ver'; + /* If PHP was compiled with PostgreSQL lib versions earlier + * than 7.4, pg_version() won't return the server version + * and so we'll have to fall back to running a query in + * order to get it. + */ + return isset($pg_version['server']) + ? $this->data_cache['version'] = $pg_version['server'] + : parent::version(); } // -------------------------------------------------------------------- @@ -494,26 +490,16 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - return pg_last_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @return string + * @return array */ - protected function _error_number() + public function error() { - // Not supported in Postgre - return ''; + return array('code' => '', 'message' => pg_last_error($this->conn_id)); } // -------------------------------------------------------------------- |