From d947eba0bdaf9d86401fdcba9e97706905cacf9d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Apr 2012 14:58:28 +0300 Subject: Multiple DB Forge improvements - Replaced driver methods _create_database(), _drop_database(), _drop_table() and _rename_table() with properties - Added defaults for the above mentioned platform-specific queries, so that not all drivers need to define them - Improved support for the SQLite, ODBC and PDO drivers --- .../database/drivers/interbase/interbase_forge.php | 59 ++++++++-------------- 1 file changed, 20 insertions(+), 39 deletions(-) (limited to 'system/database/drivers/interbase/interbase_forge.php') diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index f46043569..c850656a8 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Interbase/Firebird Forge Class * @@ -36,18 +34,22 @@ */ class CI_DB_interbase_forge extends CI_DB_forge { + protected $_drop_table = 'DROP TABLE %s'; + /** * Create database * * @param string the database name * @return string */ - protected function _create_database($filename='') + public function create_database($db_name) { - // Firebird databases are flat files, so a path is required + // Firebird databases are flat files, so a path is required + // Hostname is needed for remote access - return 'CREATE DATABASE "'.$this->hostname.':'.$filename.'"'; - + empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name; + + return parent::create_database('"'.$db_name.'"'); } // -------------------------------------------------------------------- @@ -55,14 +57,20 @@ class CI_DB_interbase_forge extends CI_DB_forge { /** * Drop database * - * @param string the database name - not used in this driver - * - the current db is dropped + * @param string the database name + * - not used in this driver, the current db is dropped * @return bool */ - protected function _drop_database($name='') + public function drop_database($db_name = '') { - return ibase_drop_db($this->conn_id); + if ( ! ibase_drop_db($this->conn_id)) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + return TRUE; } + // -------------------------------------------------------------------- /** @@ -72,7 +80,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param array the fields * @param mixed primary key(s) * @param mixed key(s) - * @param boolean should 'IF NOT EXISTS' be added to the SQL + * @param bool should 'IF NOT EXISTS' be added to the SQL * @return string */ protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) @@ -166,18 +174,6 @@ class CI_DB_interbase_forge extends CI_DB_forge { // -------------------------------------------------------------------- - /** - * Drop Table - * - * @return string - */ - protected function _drop_table($table) - { - return 'DROP TABLE '.$name; - } - - // -------------------------------------------------------------------- - /** * Alter table query * @@ -189,7 +185,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { * @param string the table name * @param string the column definition * @param string the default value - * @param boolean should 'NOT NULL' be added + * @param bool should 'NOT NULL' be added * @param string the field after which we should add the new field * @return string */ @@ -222,21 +218,6 @@ class CI_DB_interbase_forge extends CI_DB_forge { } - // -------------------------------------------------------------------- - - /** - * Rename a table - * - * Generates a platform-specific query so that a table can be renamed - * - * @param string the old table name - * @param string the new table name - * @return string - */ - protected function _rename_table($table_name, $new_table_name) - { - return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name); - } } /* End of file interbase_forge.php */ -- cgit v1.2.3-24-g4f1b