diff options
author | admin <devnull@localhost> | 2006-09-25 23:06:46 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-25 23:06:46 +0200 |
commit | 83b05a860a5f208d15942b517385848cfe4887bb (patch) | |
tree | da87851bb10fd9bdf913fb8bca9d726fb0083423 /system/database | |
parent | 6cec6a58d993fb0b1beb5fac7ea0d1cb9769c0a4 (diff) |
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB_utility.php | 60 | ||||
-rw-r--r-- | system/database/drivers/mssql/mssql_utility.php | 28 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_utility.php | 28 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_utility.php | 28 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_utility.php | 16 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_utility.php | 12 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_utility.php | 28 | ||||
-rw-r--r-- | system/database/drivers/sqlite/sqlite_utility.php | 12 |
8 files changed, 116 insertions, 96 deletions
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 128984d4f..36d74c5b3 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -232,14 +232,70 @@ class CI_DB_utility { // -------------------------------------------------------------------- + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + $sql = $this->_drop_database($name); + + if (is_bool($sql)) + { + return $sql; + } + + return $this->db->query($sql); + } + // -------------------------------------------------------------------- + /** + * List databases + * + * @access public + * @return bool + */ + function list_databases() + { + $query = $this->db->query($this->_list_database()); + $dbs = array(); + if ($query->num_rows() > 0) + { + foreach ($query->result_array() as $row) + { + $dbs[] = current($row); + } + } + + return $dbs; + } + // -------------------------------------------------------------------- - - function create_table() + /** + * Drop Table + * + * @access public + * @param string the table name + * @return bool + */ + function drop_table($name) { + $sql = $this->_drop_table($name); + + if (is_bool($sql)) + { + return $sql; + } + + return $this->db->query($sql); } + + function alter_table() { diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index 49b63b7d0..b85a420e7 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -42,13 +42,13 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { - return $this->db->query("DROP DATABASE ".$name); + return "DROP DATABASE ".$name; } // -------------------------------------------------------------------- @@ -56,22 +56,12 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { - $query = $this->db->query("EXEC sp_helpdb"); // Can also be: EXEC sp_databases - $dbs = array(); - if ($query->num_rows() > 0) - { - foreach ($query->result_array() as $row) - { - $dbs[] = current($row); - } - } - - return $dbs; + return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases } // -------------------------------------------------------------------- @@ -79,12 +69,12 @@ class CI_DB_mssql_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { - return $this->db->query("DROP TABLE ".$this->db->_escape_table($name)); + return "DROP TABLE ".$this->db->_escape_table($name); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index e5f8e850d..a0c746207 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -41,13 +41,13 @@ class CI_DB_mysql_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { - return $this->db->query("DROP DATABASE ".$name); + return "DROP DATABASE ".$name; } // -------------------------------------------------------------------- @@ -55,22 +55,12 @@ class CI_DB_mysql_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { - $query = $this->db->query("SHOW DATABASES"); - $dbs = array(); - if ($query->num_rows() > 0) - { - foreach ($query->result_array() as $row) - { - $dbs[] = current($row); - } - } - - return $dbs; + return "SHOW DATABASES"; } // -------------------------------------------------------------------- @@ -78,12 +68,12 @@ class CI_DB_mysql_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { - return $this->db->query("DROP TABLE IF EXISTS ".$this->db->_escape_table($name)); + return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 1775047ca..328661866 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -41,13 +41,13 @@ class CI_DB_mysqli_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { - return $this->db->query("DROP DATABASE ".$name); + return "DROP DATABASE ".$name; } // -------------------------------------------------------------------- @@ -55,22 +55,12 @@ class CI_DB_mysqli_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { - $query = $this->db->query("SHOW DATABASES"); - $dbs = array(); - if ($query->num_rows() > 0) - { - foreach ($query->result_array() as $row) - { - $dbs[] = current($row); - } - } - - return $dbs; + return "SHOW DATABASES"; } // -------------------------------------------------------------------- @@ -78,12 +68,12 @@ class CI_DB_mysqli_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { - return $this->db->query("DROP TABLE IF EXISTS ".$this->db->_escape_table($name)); + return "DROP TABLE IF EXISTS ".$this->db->_escape_table($name); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 74b0165cb..9c3059f41 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -34,6 +34,7 @@ class CI_DB_oci8_utility extends CI_DB_utility { */ function _create_database($name) { + return FALSE; } // -------------------------------------------------------------------- @@ -41,12 +42,13 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { + return FALSE; } // -------------------------------------------------------------------- @@ -54,11 +56,12 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { + return FALSE; } // -------------------------------------------------------------------- @@ -66,11 +69,12 @@ class CI_DB_oci8_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { + return FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 74f8d3905..5b4558f68 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -48,11 +48,11 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { // ODBC has no "drop database" command since it's // designed to connect to an existing database @@ -68,10 +68,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { // Not sure if ODBC lets you list all databases... if ($this->db_debug) @@ -86,10 +86,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { // Not a supported ODBC feature if ($this->db_debug) diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index 8e51623be..b31609aea 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -42,13 +42,13 @@ class CI_DB_postgre_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { - return $this->db->query("DROP DATABASE ".$name); + return "DROP DATABASE ".$name; } // -------------------------------------------------------------------- @@ -56,22 +56,12 @@ class CI_DB_postgre_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { - $query = $this->db->query("SELECT datname FROM pg_database"); - $dbs = array(); - if ($query->num_rows() > 0) - { - foreach ($query->result_array() as $row) - { - $dbs[] = current($row); - } - } - - return $dbs; + return "SELECT datname FROM pg_database"; } // -------------------------------------------------------------------- @@ -79,12 +69,12 @@ class CI_DB_postgre_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { - return $this->db->query("DROP TABLE ".$this->db->_escape_table($name)." CASCADE"); + return "DROP TABLE ".$this->db->_escape_table($name)." CASCADE"; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 14b406a5c..754a755e4 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -43,11 +43,11 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * Drop database * - * @access public + * @access private * @param string the database name * @return bool */ - function drop_database($name) + function _drop_database($name) { if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) { @@ -65,10 +65,10 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * List databases * - * @access public + * @access private * @return bool */ - function list_databases() + function _list_databases() { if ($this->db_debug) { @@ -82,10 +82,10 @@ class CI_DB_sqlite_utility extends CI_DB_utility { /** * Drop Table * - * @access public + * @access private * @return bool */ - function drop_table($table) + function _drop_table($table) { if ($this->db_debug) { |