From 6ca6f9471ba31f7cba9054d075b4f90382b2d410 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 25 Sep 2006 02:51:08 +0000 Subject: --- system/database/DB_utility.php | 6 ---- system/database/drivers/mssql/mssql_utility.php | 28 ++++++++++++++++ system/database/drivers/mysql/mysql_utility.php | 28 ++++++++++++++++ system/database/drivers/mysqli/mysqli_utility.php | 28 ++++++++++++++++ system/database/drivers/oci8/oci8_utility.php | 27 +++++++++++++++ system/database/drivers/odbc/odbc_utility.php | 33 +++++++++++++++++++ .../database/drivers/postgre/postgre_utility.php | 28 ++++++++++++++++ system/database/drivers/sqlite/sqlite_utility.php | 38 ++++++++++++++++++++++ system/language/english/db_lang.php | 1 + 9 files changed, 211 insertions(+), 6 deletions(-) diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index c43b39950..d96fffa04 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -212,13 +212,7 @@ class CI_DB_utility { - function create_database() - { - } - function drop_database() - { - } function show_databases() { diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index 96d112805..9ff92d41b 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -24,6 +24,34 @@ */ class CI_DB_mssql_utility extends CI_DB_utility { + + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- /** * Version number query string diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 9bf2f5aa9..d4e97867a 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -24,6 +24,33 @@ */ class CI_DB_mysql_utility extends CI_DB_utility { + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- /** * Version number query string @@ -86,6 +113,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { } + } ?> \ No newline at end of file diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index a1498a33d..9c773b4b9 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -24,6 +24,34 @@ */ class CI_DB_mysqli_utility extends CI_DB_utility { + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + /** * Version number query string * diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index fdd585d98..35b753ec6 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -25,6 +25,33 @@ class CI_DB_oci8_utility extends CI_DB_utility { + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + + } + + // -------------------------------------------------------------------- /** * Version number query string diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 837c8c881..51fec8eed 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -24,6 +24,39 @@ */ class CI_DB_odbc_utility extends CI_DB_utility { + + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + // ODBC has no "create database" command since it's + // designed to connect to an existing database + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + // ODBC has no "drop database" command since it's + // designed to connect to an existing database + return FALSE; + } + + // -------------------------------------------------------------------- + /** * Version number query string * diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index cfc475f6b..c38cf6e69 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -25,6 +25,34 @@ class CI_DB_postgre_utility extends CI_DB_utility { + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database($name) + { + return $this->db->query("CREATE DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + return $this->db->query("DROP DATABASE ".$this->db->_escape_table($name)); + } + + // -------------------------------------------------------------------- + /** * Version number query string * diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 2b99df907..8cbf0d56d 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -24,6 +24,44 @@ */ class CI_DB_sqlite_utility extends CI_DB_utility { + + /** + * Create database + * + * @access public + * @param string the database name + * @return bool + */ + function create_database() + { + // In SQLite, a database is created when you connect to the database + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Drop database + * + * @access public + * @param string the database name + * @return bool + */ + function drop_database($name) + { + if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database)) + { + if ($this->db_debug) + { + return $this->display_error('db_unable_to_drop'); + } + return FALSE; + } + return TRUE; + } + + // -------------------------------------------------------------------- + /** * Version number query string * diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php index d51bb6dce..a3d0900d0 100644 --- a/system/language/english/db_lang.php +++ b/system/language/english/db_lang.php @@ -12,6 +12,7 @@ $lang['db_del_must_use_where'] = 'Deletes are not allowed unless they contain a $lang['db_field_param_missing'] = 'To fetch fields requires the name of the table as a parameter.'; $lang['db_unsupported_function'] = 'This feature is not available for the database you are using.'; $lang['db_transaction_failure'] = 'Transaction failure: Rollback performed'; +$lang['db_unable_to_drop'] = 'Unable to drop the specified database.'; ?> \ No newline at end of file -- cgit v1.2.3-24-g4f1b