From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_forge.php') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 336e9497d..fe2a67728 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 833d504a91f7c85fa2985bcff5016a052972bd7a Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 19 Mar 2012 16:12:03 -0400 Subject: Made the rest of the db classes abstract \n except for the DB_cache class, because I'm not sure if it is directly called --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_forge.php') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index fe2a67728..192b78fa6 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -34,7 +34,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/database/ */ -class CI_DB_forge { +abstract class CI_DB_forge { public $fields = array(); public $keys = array(); -- cgit v1.2.3-24-g4f1b From 215890b015d219f0d31e8ad678b0b655e6923f3b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 20 Mar 2012 09:38:16 -0400 Subject: Remove extraneous newlines --- system/database/DB_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_forge.php') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 192b78fa6..34c502a99 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -346,4 +346,4 @@ abstract class CI_DB_forge { } /* End of file DB_forge.php */ -/* Location: ./system/database/DB_forge.php */ +/* Location: ./system/database/DB_forge.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b 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 --- system/database/DB_forge.php | 61 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'system/database/DB_forge.php') diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 34c502a99..a519575f0 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -25,10 +25,8 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** - * Database Utility Class + * Database Forge Class * * @category Database * @author EllisLab Dev Team @@ -41,6 +39,12 @@ abstract class CI_DB_forge { public $primary_keys = array(); public $db_char_set = ''; + // Platform specific SQL strings + protected $_create_database = 'CREATE DATABASE %s'; + protected $_drop_database = 'DROP DATABASE %s'; + protected $_drop_table = 'DROP TABLE IF EXISTS %s'; + protected $_rename_table = 'ALTER TABLE %s RENAME TO %s'; + public function __construct() { // Assign the main database object to $this->db @@ -59,8 +63,16 @@ abstract class CI_DB_forge { */ public function create_database($db_name) { - $sql = $this->_create_database($db_name); - return is_bool($sql) ? $sql : $this->db->query($sql); + if ($this->_create_database === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + } + elseif ( ! $this->db->query(sprintf($this->_create_database, $db_name, $this->db->char_set, $this->db->dbcollat))) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + return TRUE; } // -------------------------------------------------------------------- @@ -73,8 +85,21 @@ abstract class CI_DB_forge { */ public function drop_database($db_name) { - $sql = $this->_drop_database($db_name); - return is_bool($sql) ? $sql : $this->db->query($sql); + if ($db_name == '') + { + show_error('A table name is required for that operation.'); + return FALSE; + } + elseif ($this->_drop_database === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + } + elseif ( ! $this->db->query(sprintf($this->_drop_database, $db_name))) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE; + } + + return TRUE; } // -------------------------------------------------------------------- @@ -197,8 +222,16 @@ abstract class CI_DB_forge { */ public function drop_table($table_name) { - $sql = $this->_drop_table($this->db->dbprefix.$table_name); - return is_bool($sql) ? $sql : $this->db->query($sql); + if ($table_name == '') + { + return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE; + } + elseif ($this->_drop_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; + } + + return $this->db->query(sprintf($this->_drop_table, $this->db->escape_identifiers($this->db->dbprefix.$table_name))); } // -------------------------------------------------------------------- @@ -215,9 +248,17 @@ abstract class CI_DB_forge { if ($table_name == '' OR $new_table_name == '') { show_error('A table name is required for that operation.'); + return FALSE; + } + elseif ($this->_rename_table === FALSE) + { + return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE; } - return $this->db->query($this->_rename_table($this->db->dbprefix.$table_name, $this->db->dbprefix.$new_table_name)); + return $this->db->query(sprintf($this->_rename_table, + $this->db->escape_identifiers($this->db->dbprefix.$table_name), + $this->db->escape_identifiers($this->db->dbprefix.$new_table_name)) + ); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b