diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:19:28 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:19:28 +0100 |
commit | 08856b8738ea4fc17b13986c9f2619383cb4a6e9 (patch) | |
tree | f214c1498b4ec7cc1958b3654353748954a2a141 /system/database/drivers/postgre | |
parent | 75b2c7fd0e23afc5c0338a7b62854d38b37b9c62 (diff) |
Improve DB version() implementation and add pg_version() support
Diffstat (limited to 'system/database/drivers/postgre')
-rw-r--r-- | system/database/drivers/postgre/postgre_driver.php | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 0fcd954e9..d6681086a 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -147,14 +147,30 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * - * @access public * @return string */ - function _version() + public function version() { - return "SELECT version() AS ver"; + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (($pg_version = pg_version($this->conn_id)) === FALSE) + { + return FALSE; + } + + /* 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(); } // -------------------------------------------------------------------- @@ -323,8 +339,7 @@ class CI_DB_postgre_driver extends CI_DB { */ function insert_id() { - $v = $this->_version(); - $v = $v['server']; + $v = $this->version(); $table = func_num_args() > 0 ? func_get_arg(0) : NULL; $column = func_num_args() > 1 ? func_get_arg(1) : NULL; |