diff options
Diffstat (limited to 'system/database/drivers')
-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 |
7 files changed, 147 insertions, 2 deletions
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 |