diff options
author | admin <devnull@localhost> | 2006-09-25 05:44:04 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-25 05:44:04 +0200 |
commit | 72496373008b263e098cf6082cdce1d47d01d3f1 (patch) | |
tree | 887849565e73eaef2ffa95b3c722ed15f3e508bc /system/database | |
parent | 6ca6f9471ba31f7cba9054d075b4f90382b2d410 (diff) |
Diffstat (limited to 'system/database')
-rw-r--r-- | system/database/DB_utility.php | 7 | ||||
-rw-r--r-- | system/database/drivers/mssql/mssql_utility.php | 23 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_utility.php | 23 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_utility.php | 23 | ||||
-rw-r--r-- | system/database/drivers/oci8/oci8_utility.php | 12 | ||||
-rw-r--r-- | system/database/drivers/odbc/odbc_utility.php | 28 | ||||
-rw-r--r-- | system/database/drivers/postgre/postgre_utility.php | 23 | ||||
-rw-r--r-- | system/database/drivers/sqlite/sqlite_utility.php | 17 |
8 files changed, 147 insertions, 9 deletions
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index d96fffa04..b17b3d51c 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -211,13 +211,6 @@ class CI_DB_utility { - - - - function show_databases() - { - } - function create_table() { } diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php index 9ff92d41b..bc398e7f7 100644 --- a/system/database/drivers/mssql/mssql_utility.php +++ b/system/database/drivers/mssql/mssql_utility.php @@ -52,6 +52,29 @@ class CI_DB_mssql_utility extends CI_DB_utility { } // -------------------------------------------------------------------- + + /** + * List databases + * + * @access public + * @return bool + */ + 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; + } + + // -------------------------------------------------------------------- /** * Version number query string diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index d4e97867a..5bbf46810 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -53,6 +53,29 @@ class CI_DB_mysql_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** + * List databases + * + * @access public + * @return bool + */ + 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; + } + + // -------------------------------------------------------------------- + + /** * Version number query string * * @access public diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index 9c773b4b9..14a6ef8cf 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -53,6 +53,29 @@ class CI_DB_mysqli_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** + * List databases + * + * @access public + * @return bool + */ + 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; + } + + // -------------------------------------------------------------------- + + /** * Version number query string * * @access public diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php index 35b753ec6..03edcb2c8 100644 --- a/system/database/drivers/oci8/oci8_utility.php +++ b/system/database/drivers/oci8/oci8_utility.php @@ -34,7 +34,6 @@ class CI_DB_oci8_utility extends CI_DB_utility { */ function create_database($name) { - } // -------------------------------------------------------------------- @@ -48,7 +47,18 @@ class CI_DB_oci8_utility extends CI_DB_utility { */ function drop_database($name) { + } + // -------------------------------------------------------------------- + + /** + * List databases + * + * @access public + * @return bool + */ + function list_databases() + { } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php index 51fec8eed..42537de70 100644 --- a/system/database/drivers/odbc/odbc_utility.php +++ b/system/database/drivers/odbc/odbc_utility.php @@ -36,6 +36,10 @@ class CI_DB_odbc_utility extends CI_DB_utility { { // ODBC has no "create database" command since it's // designed to connect to an existing database + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } return FALSE; } @@ -51,7 +55,29 @@ class CI_DB_odbc_utility extends CI_DB_utility { function drop_database($name) { // ODBC has no "drop database" command since it's - // designed to connect to an existing database + // designed to connect to an existing database + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } + return FALSE; + } + + // -------------------------------------------------------------------- + + /** + * List databases + * + * @access public + * @return bool + */ + function list_databases() + { + // Not sure if ODBC lets you list all databases... + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } return FALSE; } diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php index c38cf6e69..103f8d553 100644 --- a/system/database/drivers/postgre/postgre_utility.php +++ b/system/database/drivers/postgre/postgre_utility.php @@ -54,6 +54,29 @@ class CI_DB_postgre_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** + * List databases + * + * @access public + * @return bool + */ + 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; + } + + // -------------------------------------------------------------------- + + /** * Version number query string * * @access public diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php index 8cbf0d56d..5f1f02eab 100644 --- a/system/database/drivers/sqlite/sqlite_utility.php +++ b/system/database/drivers/sqlite/sqlite_utility.php @@ -63,6 +63,23 @@ class CI_DB_sqlite_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** + * List databases + * + * @access public + * @return bool + */ + function list_databases() + { + if ($this->db_debug) + { + return $this->display_error('db_unsuported_feature'); + } + return array(); + } + + // -------------------------------------------------------------------- + + /** * Version number query string * * @access public |