summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/database/DB_result.php38
-rw-r--r--system/database/DB_utility.php50
-rw-r--r--system/database/drivers/mssql/mssql_driver.php66
-rw-r--r--system/database/drivers/mssql/mssql_utility.php59
-rw-r--r--system/database/drivers/mysql/mysql_driver.php62
-rw-r--r--system/database/drivers/mysql/mysql_utility.php58
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php62
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php58
-rw-r--r--system/database/drivers/oci8/oci8_driver.php63
-rw-r--r--system/database/drivers/oci8/oci8_utility.php77
-rw-r--r--system/database/drivers/odbc/odbc_driver.php62
-rw-r--r--system/database/drivers/odbc/odbc_utility.php58
-rw-r--r--system/database/drivers/postgre/postgre_driver.php60
-rw-r--r--system/database/drivers/postgre/postgre_utility.php58
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php63
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php61
-rw-r--r--system/libraries/Controller.php46
-rw-r--r--system/libraries/Loader.php25
18 files changed, 488 insertions, 538 deletions
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index abb6b588b..970a0db68 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -243,44 +243,6 @@ class CI_DB_result {
return $result[$this->current_row];
}
- /**
- * Number of rows in the result set
- *
- * @access public
- * @return integer
- */
- function num_rows()
- {
- // Result supplied by the result adaptor class
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Number of fields in the result set
- *
- * @access public
- * @return integer
- */
- function num_fields()
- {
- // Result supplied by the result adaptor class
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Field data
- *
- * Generates an array of objects containing field meta-data
- *
- * @access public
- * @return array
- */
- function field_data()
- {
- // Result supplied by the result adaptor class
- }
}
?> \ No newline at end of file
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 39dc2cca2..c43b39950 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -24,9 +24,15 @@
*/
class CI_DB_utility {
+ var $db;
+
+ function CI_DB_utility()
+ {
+ // Assign the main database object to $this->db
+ $obj =& get_instance();
+ $this->db =& $obj->db;
+ }
-
- // --------------------------------------------------------------------
/**
* Database Version Number. Returns a string containing the
@@ -39,19 +45,19 @@ class CI_DB_utility {
{
if (FALSE === ($sql = $this->_version()))
{
- if ($this->db_debug)
+ if ($this->db->db_debug)
{
- return $this->display_error('db_unsupported_function');
+ return $this->db->display_error('db_unsupported_function');
}
return FALSE;
}
- if ($this->dbdriver == 'oci8')
+ if ($this->db->dbdriver == 'oci8')
{
return $sql;
- }
+ }
- $query = $this->query($sql);
+ $query = $this->db->query($sql);
$row = $query->row();
return $row->ver;
}
@@ -65,18 +71,18 @@ class CI_DB_utility {
* @return array
*/
function tables()
- {
+ {
if (FALSE === ($sql = $this->_show_tables()))
{
- if ($this->db_debug)
+ if ($this->db->db_debug)
{
- return $this->display_error('db_unsupported_function');
+ return $this->db->display_error('db_unsupported_function');
}
return FALSE;
}
$retval = array();
- $query = $this->query($sql);
+ $query = $this->db->query($sql);
if ($query->num_rows() > 0)
{
@@ -104,8 +110,8 @@ class CI_DB_utility {
* @return boolean
*/
function table_exists($table_name)
- {
- return ( ! in_array($this->dbprefix.$table_name, $this->tables())) ? FALSE : TRUE;
+ {
+ return ( ! in_array($this->db->dbprefix.$table_name, $this->tables())) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
@@ -121,23 +127,23 @@ class CI_DB_utility {
{
if ($table == '')
{
- if ($this->db_debug)
+ if ($this->db->db_debug)
{
- return $this->display_error('db_field_param_missing');
+ return $this->db->display_error('db_field_param_missing');
}
return FALSE;
}
- if (FALSE === ($sql = $this->_show_columns($this->dbprefix.$table)))
+ if (FALSE === ($sql = $this->_show_columns($this->db->dbprefix.$table)))
{
- if ($this->db_debug)
+ if ($this->db->db_debug)
{
- return $this->display_error('db_unsupported_function');
+ return $this->db->display_error('db_unsupported_function');
}
return FALSE;
}
- $query = $this->query($sql);
+ $query = $this->db->query($sql);
$retval = array();
foreach($query->result_array() as $row)
@@ -168,14 +174,14 @@ class CI_DB_utility {
{
if ($table == '')
{
- if ($this->db_debug)
+ if ($this->db->db_debug)
{
- return $this->display_error('db_field_param_missing');
+ return $this->db->display_error('db_field_param_missing');
}
return FALSE;
}
- return $this->_field_data($this->dbprefix.$table);
+ return $this->_field_data($this->db->dbprefix.$table);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index cd808da46..38fce1134 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -386,71 +386,7 @@ class CI_DB_mssql_driver extends CI_DB {
function _close($conn_id)
{
mssql_close($conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * 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->_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)
- {
- $sql = "SELECT TOP 1 FROM ".$this->_escape_table($table);
- $query = $this->query($sql);
- return $query->field_data();
- }
-
-
+ }
}
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index a76e1f14f..96d112805 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -22,20 +22,71 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_mssql_utility {
+class CI_DB_mssql_utility extends CI_DB_utility {
+
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+ // --------------------------------------------------------------------
+
/**
- * Some function
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index fc7f6780b..545ac1986 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -410,69 +410,7 @@ class CI_DB_mysql_driver extends CI_DB {
{
mysql_close($conn_id);
}
-
- // --------------------------------------------------------------------
-
- /**
- * 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->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->_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)
- {
- $sql = "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
?> \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 8dd764888..9bf2f5aa9 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -22,20 +22,70 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_mysql_utility {
+class CI_DB_mysql_utility extends CI_DB_utility {
+
/**
- * Some function
+ * Version number query string
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 959384164..adc482dfe 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -412,68 +412,6 @@ class CI_DB_mysqli_driver extends CI_DB {
mysqli_close($conn_id);
}
- // --------------------------------------------------------------------
-
- /**
- * 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->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->_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)
- {
- $sql = "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 02b423c30..a1498a33d 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -22,20 +22,70 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_mysqli_utility {
+class CI_DB_mysqli_utility extends CI_DB_utility {
/**
- * Some function
+ * Version number query string
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index bfc38a435..f7f4bd143 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -539,69 +539,6 @@ class CI_DB_oci8_driver extends CI_DB {
ocilogoff($conn_id);
}
- // --------------------------------------------------------------------
-
- /**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- $ver = ociserverversion($this->conn_id);
- return $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 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)
- {
- $sql = "SELECT * FROM ".$this->_escape_table($table)." where rownum = 1";
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index f1e327a3e..fdd585d98 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -22,19 +22,70 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_oci8_utility {
-
- /**
- * Some function
- *
- * @access public
- * @return integer
- */
- function something()
- {
- }
-
- // --------------------------------------------------------------------
+class CI_DB_oci8_utility extends CI_DB_utility {
+
+
+
+ /**
+ * 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)
+ {
+ $sql = "SELECT * FROM ".$this->db->_escape_table($table)." where rownum = 1";
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
}
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index c05abd082..bef6258de 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -386,68 +386,6 @@ class CI_DB_odbc_driver extends CI_DB {
odbc_close($conn_id);
}
- // --------------------------------------------------------------------
-
- /**
- * 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->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->_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)
- {
- $sql = "SELECT TOP 1 FROM ".$this->_escape_table($table);
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index f2b5602cc..837c8c881 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -22,20 +22,70 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/database/
*/
-class CI_DB_odbc_utility {
+class CI_DB_odbc_utility extends CI_DB_utility {
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return "SELECT version() AS ver";
+ }
+ // --------------------------------------------------------------------
+
/**
- * Some function
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT TOP 1 FROM ".$this->db->_escape_table($table);
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 03817188f..9c8a18eb5 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -419,66 +419,6 @@ class CI_DB_postgre_driver extends CI_DB {
pg_close($conn_id);
}
- // --------------------------------------------------------------------
-
- /**
- * 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->_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)
- {
- $sql = "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index 760be81a0..cfc475f6b 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -22,20 +22,70 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_postgre_utility {
+class CI_DB_postgre_utility extends CI_DB_utility {
+
/**
- * Some function
+ * Version number query string
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
}
?> \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index f8318b814..603984575 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -413,69 +413,6 @@ class CI_DB_sqlite_driver extends CI_DB {
sqlite_close($conn_id);
}
- // --------------------------------------------------------------------
-
- /**
- * 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)
- {
- $sql = "SELECT * FROM ".$this->_escape_table($table)." LIMIT 1";
- $query = $this->query($sql);
- return $query->field_data();
- }
-
}
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 3cbec6f14..2b99df907 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -22,20 +22,71 @@
* @author Rick Ellis
* @link http://www.codeigniter.com/user_guide/database/
*/
-class CI_DB_sqlite_utility {
-
+class CI_DB_sqlite_utility extends CI_DB_utility {
+
+ /**
+ * Version number query string
+ *
+ * @access public
+ * @return string
+ */
+ function _version()
+ {
+ return sqlite_libversion();
+ }
+
+ // --------------------------------------------------------------------
+
/**
- * Some function
+ * Show table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
*
* @access public
- * @return integer
+ * @return string
*/
- function something()
+ 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)
+ {
+ $sql = "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1";
+ $query = $this->db->query($sql);
+ return $query->field_data();
+ }
+
+
+
}
?> \ No newline at end of file
diff --git a/system/libraries/Controller.php b/system/libraries/Controller.php
index b91cf3b07..5fdbd9f9f 100644
--- a/system/libraries/Controller.php
+++ b/system/libraries/Controller.php
@@ -384,7 +384,7 @@ class Controller extends CI_Base {
require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver'.EXT);
// Instantiate the DB adapter
- $driver = 'CI_DB_'. $params['dbdriver'].'_driver';
+ $driver = 'CI_DB_'.$params['dbdriver'].'_driver';
$DB = new $driver($params);
if ($return === TRUE)
@@ -397,7 +397,49 @@ class Controller extends CI_Base {
$obj->db =& $DB;
}
// END _ci_init_database()
-
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Initialize Database Utilities Class
+ *
+ * @access private
+ * @param mixed database platform
+ * @param bool whether to return the object
+ * @return void
+ */
+ function _ci_init_dbutils($db = '', $return = FALSE)
+ {
+ if ($this->_ci_is_loaded('dbutils') == TRUE AND $return == FALSE)
+ {
+ return;
+ }
+
+ if ($this->_ci_is_loaded('db') == FALSE)
+ {
+ $this->_ci_init_database();
+ }
+
+ require_once(BASEPATH.'database/DB_utility'.EXT);
+ require_once(BASEPATH.'database/drivers/'.$this->db->dbdriver.'/'.$this->db->dbdriver.'_utility'.EXT);
+
+
+ // Instantiate the DB adapter
+ $driver = 'CI_DB_'.$this->db->dbdriver.'_utility';
+ $DB = new $driver();
+
+ if ($return === TRUE)
+ {
+ return $DB;
+ }
+
+ $obj =& get_instance();
+ $obj->ci_is_loaded[] = 'dbutils';
+ $obj->dbutil =& $DB;
+ }
+ // END _ci_init_database()
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Loader.php b/system/libraries/Loader.php
index d966e2862..f4a9f821d 100644
--- a/system/libraries/Loader.php
+++ b/system/libraries/Loader.php
@@ -108,7 +108,7 @@ class CI_Loader {
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
- * @return mixed
+ * @return object
*/
function database($db = '', $return = FALSE, $active_record = FALSE)
{
@@ -125,6 +125,29 @@ class CI_Loader {
}
}
// END database()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database Utilities Loader
+ *
+ * @access public
+ * @param string the DB platform
+ * @param bool whether to return the DB object
+ * @return object
+ */
+ function dbutils($db = '', $return = FALSE)
+ {
+ $obj =& get_instance();
+
+ if ( ! is_bool($return))
+ {
+ $return = FALSE;
+ }
+
+ return $obj->_ci_init_dbutils($db, $return);
+ }
+ // END dbutils()
// --------------------------------------------------------------------