diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 3f7c826..d25135e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -145,6 +145,49 @@
// --------------------------------------------------------------------
/**
+ * 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 @@
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();
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 950db7d..f98448a 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -33,182 +33,6 @@
$this->db =& $obj->db;
}
-
- /**
- * 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->db_debug)
- {
- return $this->db->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- if ($this->db->dbdriver == 'oci8')
- {
- return $sql;
- }
-
- $query = $this->db->query($sql);
- $row = $query->row();
- return $row->ver;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Returns an array of table names
- *
- * @access public
- * @return array
- */
- function tables()
- {
- if (FALSE === ($sql = $this->_show_tables()))
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- $retval = array();
- $query = $this->db->query($sql);
-
- if ($query->num_rows() > 0)
- {
- foreach($query->result_array() as $row)
- {
- if (isset($row['TABLE_NAME']))
- {
- $retval[] = $row['TABLE_NAME'];
- }
- else
- {
- $retval[] = array_shift($row);
- }
- }
- }
-
- return $retval;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Determine if a particular table exists
- * @access public
- * @return boolean
- */
- function table_exists($table_name)
- {
- return ( ! in_array($this->db->dbprefix.$table_name, $this->tables())) ? FALSE : TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Fetch MySQL Field Names
- *
- * @access public
- * @param string the table name
- * @return array
- */
- function field_names($table = '')
- {
- if ($table == '')
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_field_param_missing');
- }
- return FALSE;
- }
-
- if (FALSE === ($sql = $this->_show_columns($this->db->dbprefix.$table)))
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsupported_function');
- }
- return FALSE;
- }
-
- $query = $this->db->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->db_debug)
- {
- return $this->db->display_error('db_field_param_missing');
- }
- return FALSE;
- }
-
- $query = $this->db->query($this->_field_data($this->db->dbprefix.$table));
- return $query->field_data();
- }
-
// --------------------------------------------------------------------
/**
@@ -273,6 +97,58 @@
return $dbs;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Returns an array of table names
+ *
+ * @access public
+ * @return array
+ */
+ function list_tables()
+ {
+ if (FALSE === ($sql = $this->_list_tables()))
+ {
+ if ($this->db->db_debug)
+ {
+ return $this->db->display_error('db_unsupported_function');
+ }
+ return FALSE;
+ }
+
+ $retval = array();
+ $query = $this->db->query($sql);
+
+ if ($query->num_rows() > 0)
+ {
+ foreach($query->result_array() as $row)
+ {
+ if (isset($row['TABLE_NAME']))
+ {
+ $retval[] = $row['TABLE_NAME'];
+ }
+ else
+ {
+ $retval[] = array_shift($row);
+ }
+ }
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Determine if a particular table exists
+ * @access public
+ * @return boolean
+ */
+ function table_exists($table_name)
+ {
+ return ( ! in_array($this->db->dbprefix.$table_name, $this->list_tables())) ? FALSE : TRUE;
+ }
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 38fce11..3f5e533 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -66,6 +66,19 @@
{
return @mssql_select_db($this->database, $this->conn_id);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
// --------------------------------------------------------------------
@@ -249,6 +262,38 @@
// --------------------------------------------------------------------
/**
+ * List columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access private
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT TOP 1 FROM ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index cf15104..96b8180 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -67,6 +67,21 @@
// --------------------------------------------------------------------
/**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
@@ -78,67 +93,6 @@
}
// --------------------------------------------------------------------
-
- /**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->db->_escape_table($table)."'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
- }
-
-
- // --------------------------------------------------------------------
/**
* Optimize table query
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 545ac19..b6c4eb7 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -73,7 +73,20 @@
{
return @mysql_select_db($this->database, $this->conn_id);
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+
// --------------------------------------------------------------------
/**
@@ -267,6 +280,38 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SHOW COLUMNS FROM ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 800a90c..9ba4a79 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -66,6 +66,21 @@
// --------------------------------------------------------------------
/**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SHOW TABLES FROM `".$this->db->database."`";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
@@ -79,66 +94,6 @@
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SHOW TABLES FROM `".$this->db->database."`";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SHOW COLUMNS FROM ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index adc482d..d6e9674 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -75,7 +75,20 @@
{
return @mysqli_select_db($this->conn_id, $this->database);
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+
// --------------------------------------------------------------------
/**
@@ -270,6 +283,38 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SHOW COLUMNS FROM ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 8c9e1e9..754ffbd 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -62,7 +62,22 @@
{
return "SHOW DATABASES";
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SHOW TABLES FROM `".$this->db->database."`";
+ }
+
// --------------------------------------------------------------------
/**
@@ -75,66 +90,6 @@
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name);
}
-
- // --------------------------------------------------------------------
-
- /**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SHOW TABLES FROM `".$this->db->database."`";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SHOW COLUMNS FROM ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
- }
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index f7f4bd1..bc0a100 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -91,6 +91,19 @@
return TRUE;
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return ociserverversion($this->conn_id);
+ }
+
// --------------------------------------------------------------------
/**
@@ -102,10 +115,8 @@
*/
function _execute($sql)
{
- // oracle must parse the query before it
- // is run, all of the actions with
- // the query are based off the statement id
- // returned by ociparse
+ // oracle must parse the query before it is run. All of the actions with
+ // the query are based on the statement id returned by ociparse
$this->_set_stmt_id($sql);
ocisetprefetch($this->stmt_id, 1000);
return @ociexecute($this->stmt_id, $this->_commit);
@@ -391,6 +402,38 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." where rownum = 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index 011e971..dc259ac 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -64,6 +64,21 @@
return FALSE;
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "select TABLE_NAME FROM ALL_TABLES";
+ }
+
// --------------------------------------------------------------------
/**
@@ -79,67 +94,6 @@
// --------------------------------------------------------------------
- /**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return ociserverversion($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "select TABLE_NAME FROM ALL_TABLES";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->db->_escape_table($table)." where rownum = 1";
- }
-
-
- // --------------------------------------------------------------------
-
/**
* Optimize table query
*
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index bef6258..cdde2e2 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -67,7 +67,20 @@
// Not needed for ODBC
return TRUE;
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+
// --------------------------------------------------------------------
/**
@@ -250,6 +263,38 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SHOW COLUMNS FROM ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT TOP 1 FROM ".$this->_escape_table($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 2932da8..3d420f6 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -84,6 +84,21 @@
// --------------------------------------------------------------------
/**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SHOW TABLES FROM `".$this->db->database."`";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
@@ -102,66 +117,6 @@
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SHOW TABLES FROM `".$this->db->database."`";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SHOW COLUMNS FROM ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 9c8a18e..0262841 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -71,7 +71,20 @@
// Not needed for Postgre so we'll return TRUE
return TRUE;
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+
// --------------------------------------------------------------------
/**
@@ -277,6 +290,38 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$this->_escape_table($table)."'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index b2fdd5f..0ee448f 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -63,7 +63,22 @@
{
return "SELECT datname FROM pg_database";
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+ }
+
// --------------------------------------------------------------------
/**
@@ -80,66 +95,6 @@
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- return "SELECT column_name FROM information_schema.columns WHERE table_name ='".$this->db->_escape_table($table)."'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 6039845..45dd7a8 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -88,6 +88,19 @@
{
return TRUE;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return sqlite_libversion();
+ }
// --------------------------------------------------------------------
@@ -269,6 +282,39 @@
// --------------------------------------------------------------------
/**
+ * Show columnn query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function _list_columns($table = '')
+ {
+ // Not supported
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @access public
+ * @param string the table name
+ * @return object
+ */
+ function _field_data($table)
+ {
+ return "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* The error message string
*
* @access private
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index e9f4eb6..43c43e0 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -80,6 +80,21 @@
// --------------------------------------------------------------------
/**
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @access private
+ * @return string
+ */
+ function _list_tables()
+ {
+ return "SELECT name from sqlite_master WHERE type='table'";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Drop Table
*
* @access private
@@ -97,67 +112,6 @@
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return sqlite_libversion();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show table query
- *
- * Generates a platform-specific query string so that the table names can be fetched
- *
- * @access public
- * @return string
- */
- function _show_tables()
- {
- return "SELECT name from sqlite_master WHERE type='table'";
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Show columnn query
- *
- * Generates a platform-specific query string so that the column names can be fetched
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function _show_columns($table = '')
- {
- // Not supported
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
- *
- * @access public
- * @param string the table name
- * @return object
- */
- function _field_data($table)
- {
- return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Optimize table query
*
* Generates a platform-specific query so that a table can be optimized
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index 5fdbd9f..da5f2e0 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -409,7 +409,7 @@
* @param bool whether to return the object
* @return void
*/
- function _ci_init_dbutils($db = '', $return = FALSE)
+ function _ci_init_dbutil($db = '', $return = FALSE)
{
if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
{
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index b69d3f0..833e376 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -136,7 +136,7 @@
* @param bool whether to return the DB object
* @return object
*/
- function dbutils($db = '', $return = FALSE)
+ function dbutil($db = '', $return = FALSE)
{
$obj =& get_instance();
@@ -145,7 +145,7 @@
$return = FALSE;
}
- return $obj->_ci_init_dbutils($db, $return);
+ return $obj->_ci_init_dbutil($db, $return);
}
// END dbutils()