summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-26 01:26:25 +0200
committeradmin <devnull@localhost>2006-09-26 01:26:25 +0200
commit9cd4e8e639a1a09fd6ca426f1af94586f30d4a80 (patch)
tree7abdc9289f336ba520a88e7b92d4a13fa5738287 /system/database/DB_driver.php
parentd125c5c9e9cf3d53e4d6e166e7b44001d02191a3 (diff)
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php140
1 files changed, 140 insertions, 0 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 3f7c82627..d25135ea6 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -145,6 +145,49 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * The name of the platform in use (mysql, mssql, etc...)
+ *
+ * @access public
+ * @return string
+ */
+ function platform()
+ {
+ return $this->dbdriver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Version Number. Returns a string containing the
+ * version of the database being used
+ *
+ * @access public
+ * @return string
+ */
+ function version()
+ {
+ if (FALSE === ($sql = $this->_version()))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ if ($this->dbdriver == 'oci8')
+ {
+ return $sql;
+ }
+
+ $query = $this->query($sql);
+ $row = $query->row();
+ return $row->ver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Execute the query
*
* Accepts an SQL string as input and returns a result object upon
@@ -483,6 +526,103 @@ class CI_DB_driver {
return $str;
}
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Primary
+ *
+ * Retrieves the primary key. It assumes that the row in the first
+ * position is the primary key
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function primary($table = '')
+ {
+ $fields = $this->field_names($table);
+
+ if ( ! is_array($fields))
+ {
+ return FALSE;
+ }
+
+ return current($fields);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch MySQL Field Names
+ *
+ * @access public
+ * @param string the table name
+ * @return array
+ */
+ function field_names($table = '')
+ {
+ if ($table == '')
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_field_param_missing');
+ }
+ return FALSE;
+ }
+
+ if (FALSE === ($sql = $this->_list_columns($this->dbprefix.$table)))
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ $query = $this->query($sql);
+
+ $retval = array();
+ foreach($query->result_array() as $row)
+ {
+ if (isset($row['COLUMN_NAME']))
+ {
+ $retval[] = $row['COLUMN_NAME'];
+ }
+ else
+ {
+ $retval[] = current($row);
+ }
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns an object with field data
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function field_data($table = '')
+ {
+ if ($table == '')
+ {
+ if ($this->db_debug)
+ {
+ return $this->display_error('db_field_param_missing');
+ }
+ return FALSE;
+ }
+
+ $query = $this->query($this->_field_data($this->dbprefix.$table));
+ return $query->field_data();
+ }
+
// --------------------------------------------------------------------
/**