diff options
Diffstat (limited to 'system/database/drivers')
-rw-r--r-- | system/database/drivers/mssql/mssql_driver.php | 45 | ||||
-rw-r--r-- | system/database/drivers/mssql/mssql_utility.php | 62 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 47 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_utility.php | 59 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_driver.php | 47 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_utility.php | 59 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_driver.php | 51 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_utility.php | 72 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_driver.php | 47 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_utility.php | 69 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_driver.php | 47 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_utility.php | 59 | ||||
-rw-r--r-- | system/database/drivers/sqlite/sqlite_driver.php | 46 | ||||
-rw-r--r-- | system/database/drivers/sqlite/sqlite_utility.php | 68 |
14 files changed, 387 insertions, 391 deletions
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 38fce1134..3f5e53345 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -66,6 +66,19 @@ class CI_DB_mssql_driver extends CI_DB { { 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 @@ class CI_DB_mssql_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 cf15104c6..96b8180b8 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -67,76 +67,30 @@ class CI_DB_mssql_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - return "DROP TABLE ".$this->db->_escape_table($name); - } - - // -------------------------------------------------------------------- - - /** - * Version number query string - * - * @access public - * @return string - */ - function _version() - { - return "SELECT version() AS ver"; - } - - // -------------------------------------------------------------------- - - /** - * Show table query + * List table query * * Generates a platform-specific query string so that the table names can be fetched * - * @access public + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT TOP 1 FROM ".$this->db->_escape_table($table); + return "DROP TABLE ".$this->db->_escape_table($name); } - // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 545ac1986..b6c4eb7ea 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -73,7 +73,20 @@ class CI_DB_mysql_driver extends CI_DB { { 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 @@ class CI_DB_mysql_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 800a90c7a..9ba4a79c5 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -66,74 +66,29 @@ class CI_DB_mysql_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - 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 + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1"; + return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index adc482dfe..d6e967498 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -75,7 +75,20 @@ class CI_DB_mysqli_driver extends CI_DB { { 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 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 8c9e1e960..754ffbda2 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -62,33 +62,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility { { return "SHOW DATABASES"; } - - // -------------------------------------------------------------------- - /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - 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"; - } - // -------------------------------------------------------------------- /** @@ -96,44 +70,25 @@ class CI_DB_mysqli_utility extends CI_DB_utility { * * Generates a platform-specific query string so that the table names can be fetched * - * @access public + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1"; + return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index f7f4bd143..bc0a100c2 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -91,6 +91,19 @@ class CI_DB_oci8_driver extends CI_DB { return TRUE; } + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @access public + * @return string + */ + function _version() + { + return ociserverversion($this->conn_id); + } + // -------------------------------------------------------------------- /** @@ -102,10 +115,8 @@ class CI_DB_oci8_driver extends CI_DB { */ 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 @@ class CI_DB_oci8_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 011e971d9..dc259ac39 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -64,32 +64,6 @@ class CI_DB_oci8_utility extends CI_DB_utility { return FALSE; } - // -------------------------------------------------------------------- - - /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - return FALSE; - } - - // -------------------------------------------------------------------- - - /** - * Version number query string - * - * @access public - * @return string - */ - function _version() - { - return ociserverversion($this->conn_id); - } - // -------------------------------------------------------------------- /** @@ -97,46 +71,26 @@ class CI_DB_oci8_utility extends CI_DB_utility { * * Generates a platform-specific query string so that the table names can be fetched * - * @access public + * @access private * @return string */ - function _show_tables() + function _list_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"; - } + // -------------------------------------------------------------------- + /** + * Drop Table + * + * @access private + * @return bool + */ + function _drop_table($table) + { + return FALSE; + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index bef6258de..cdde2e2ea 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -67,7 +67,20 @@ class CI_DB_odbc_driver extends CI_DB { // 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 @@ class CI_DB_odbc_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 2932da874..3d420f69d 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -84,79 +84,34 @@ class CI_DB_odbc_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - // Not a supported ODBC feature - if ($this->db_debug) - { - return $this->display_error('db_unsuported_feature'); - } - return FALSE; - } - - // -------------------------------------------------------------------- - - /** - * 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 + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT TOP 1 FROM ".$this->db->_escape_table($table); + // Not a supported ODBC feature + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } + return FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 9c8a18eb5..026284118 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -71,7 +71,20 @@ class CI_DB_postgre_driver extends CI_DB { // 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 @@ class CI_DB_postgre_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 b2fdd5fd4..0ee448f9e 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -63,32 +63,6 @@ class CI_DB_postgre_utility extends CI_DB_utility { { return "SELECT datname FROM pg_database"; } - - // -------------------------------------------------------------------- - - /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - return "DROP TABLE ".$this->db->_escape_table($name)." CASCADE"; - } - - // -------------------------------------------------------------------- - - /** - * Version number query string - * - * @access public - * @return string - */ - function _version() - { - return "SELECT version() AS ver"; - } // -------------------------------------------------------------------- @@ -97,44 +71,25 @@ class CI_DB_postgre_utility extends CI_DB_utility { * * Generates a platform-specific query string so that the table names can be fetched * - * @access public + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1"; + return "DROP TABLE ".$this->db->_escape_table($name)." CASCADE"; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index 603984575..45dd7a892 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -88,6 +88,19 @@ class CI_DB_sqlite_driver extends CI_DB { { return TRUE; } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @access public + * @return string + */ + function _version() + { + return sqlite_libversion(); + } // -------------------------------------------------------------------- @@ -269,6 +282,39 @@ class CI_DB_sqlite_driver extends CI_DB { // -------------------------------------------------------------------- /** + * 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 e9f4eb64e..43c43e03c 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -80,79 +80,33 @@ class CI_DB_sqlite_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** - * Drop Table - * - * @access private - * @return bool - */ - function _drop_table($table) - { - if ($this->db_debug) - { - return $this->display_error('db_unsuported_feature'); - } - return array(); - } - - // -------------------------------------------------------------------- - - /** - * 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 + * @access private * @return string */ - function _show_tables() + function _list_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 + * Drop Table * - * @access public - * @param string the table name - * @return object + * @access private + * @return bool */ - function _field_data($table) + function _drop_table($table) { - return "SELECT * FROM ".$this->db->_escape_table($table)." LIMIT 1"; + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } + return array(); } // -------------------------------------------------------------------- |