summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-03 02:19:28 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-03 02:19:28 +0100
commit08856b8738ea4fc17b13986c9f2619383cb4a6e9 (patch)
treef214c1498b4ec7cc1958b3654353748954a2a141 /system/database/DB_driver.php
parent75b2c7fd0e23afc5c0338a7b62854d38b37b9c62 (diff)
Improve DB version() implementation and add pg_version() support
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php46
1 files changed, 25 insertions, 21 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 075cab2c9..b41a42051 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -222,36 +222,40 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Database Version Number. Returns a string containing the
- * version of the database being used
+ * Database version number
+ *
+ * Returns a string containing the version of the database being used.
+ * Most drivers will override this method.
*
- * @access public
* @return string
*/
- function version()
+ public function version()
{
- if (FALSE === ($sql = $this->_version()))
+ if (isset($this->data_cache['version']))
{
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
+ return $this->data_cache['version'];
}
- // Some DBs have functions that return the version, and don't run special
- // SQL queries per se. In these instances, just return the result.
- $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli', 'interbase');
-
- if (in_array($this->dbdriver, $driver_version_exceptions))
- {
- return $sql;
- }
- else
+ if (FALSE === ($sql = $this->_version()))
{
- $query = $this->query($sql);
- return $query->row('ver');
+ return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
+
+ $query = $this->query($sql);
+ $query = $query->row();
+ return $this->data_cache['version'] = $query->ver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @return string
+ */
+ protected function _version()
+ {
+ return 'SELECT VERSION() AS ver';
}
// --------------------------------------------------------------------