summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/postgre/postgre_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/postgre/postgre_driver.php')
-rw-r--r--system/database/drivers/postgre/postgre_driver.php60
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));
}
// --------------------------------------------------------------------