From 7f55d6133b70346a428ae481d1fe57bf4d4d2320 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 13:44:28 +0200 Subject: Improve the CUBRID database driver --- system/database/drivers/cubrid/cubrid_forge.php | 136 ++++++++---------------- 1 file changed, 46 insertions(+), 90 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 85e740057..ce5aa2098 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -1,13 +1,13 @@ -$attributes) + foreach ($fields as $field => $attributes) { // Numeric field names aren't allowed in databases, so if the key is // numeric, we know it was assigned by PHP and the developer manually // entered the field information, so we'll simply add it to the list if (is_numeric($field)) { - $sql .= "\n\t$attributes"; + $sql .= "\n\t".$attributes; } else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\""; - - if (array_key_exists('NAME', $attributes)) - { - $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' '; - } + $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"' + .(array_key_exists('NAME', $attributes) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); if (array_key_exists('TYPE', $attributes)) { @@ -113,9 +104,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge { case 'numeric': $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; break; - case 'enum': // As of version 8.4.0 CUBRID does not support - // enum data type. - break; + case 'enum': // As of version 8.4.0 CUBRID does not support enum data type + break; case 'set': $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; break; @@ -125,36 +115,19 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } } + /* As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type. + * Will be supported in the next release as a part of MySQL Compatibility. + * if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) { - //$sql .= ' UNSIGNED'; - // As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type. - // Will be supported in the next release as a part of MySQL Compatibility. - } - - if (array_key_exists('DEFAULT', $attributes)) - { - $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\''; - } - - if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) - { - $sql .= ' NULL'; - } - else - { - $sql .= ' NOT NULL'; + $sql .= ' UNSIGNED'; } + */ - if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) - { - $sql .= ' AUTO_INCREMENT'; - } - - if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) - { - $sql .= ' UNIQUE'; - } + $sql .= (array_key_exists('DEFAULT', $attributes) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') + .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') + .((array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); } // don't add a comma on the end of the last field @@ -172,7 +145,6 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Create Table * - * @access private * @param string the table name * @param mixed the fields * @param mixed primary key(s) @@ -180,28 +152,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param boolean should 'IF NOT EXISTS' be added to the SQL * @return bool */ - function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { $sql = 'CREATE TABLE '; + /* As of version 8.4.0 CUBRID does not support this SQL syntax. if ($if_not_exists === TRUE) { - //$sql .= 'IF NOT EXISTS '; - // As of version 8.4.0 CUBRID does not support this SQL syntax. + $sql .= 'IF NOT EXISTS '; } + */ - $sql .= $this->db->_escape_identifiers($table)." ("; - - $sql .= $this->_process_fields($fields); + $sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields); // If there is a PK defined if (count($primary_keys) > 0) { - $key_name = "pk_" . $table . "_" . - $this->db->_protect_identifiers(implode('_', $primary_keys)); - - $primary_keys = $this->db->_protect_identifiers($primary_keys); - $sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")"; + $key_name = 'pk_'.$table.'_'.$this->db->protect_identifiers(implode('_', $primary_keys)); + $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -210,22 +178,20 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { if (is_array($key)) { - $key_name = $this->db->_protect_identifiers(implode('_', $key)); - $key = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers(implode('_', $key)); + $key = $this->db->protect_identifiers($key); } else { - $key_name = $this->db->_protect_identifiers($key); + $key_name = $this->db->protect_identifiers($key); $key = array($key_name); } - - $sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")"; + + $sql .= ",\n\tKEY ".$key_name.' ('.implode(', ', $key).')'; } } - $sql .= "\n);"; - - return $sql; + return $sql."\n);"; } // -------------------------------------------------------------------- @@ -233,12 +199,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /** * Drop Table * - * @access private * @return string */ - function _drop_table($table) + public function _drop_table($table) { - return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table); + return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table); } // -------------------------------------------------------------------- @@ -249,31 +214,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * Generates a platform-specific query so that a table can be altered * Called by add_column(), drop_column(), and column_alter(), * - * @access private * @param string the ALTER type (ADD, DROP, CHANGE) * @param string the column name * @param array fields * @param string the field after which we should add the new field - * @return object + * @return string */ - function _alter_table($alter_type, $table, $fields, $after_field = '') + public function _alter_table($alter_type, $table, $fields, $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type "; + $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; // DROP has everything it needs now. - if ($alter_type == 'DROP') - { - return $sql.$this->db->_protect_identifiers($fields); - } - - $sql .= $this->_process_fields($fields); - - if ($after_field != '') + if ($alter_type === 'DROP') { - $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field); + return $sql.$this->db->protect_identifiers($fields); } - return $sql; + return $sql.$this->_process_fields($fields) + .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } // -------------------------------------------------------------------- @@ -283,18 +241,16 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * * Generates a platform-specific query so that a table can be renamed * - * @access private * @param string the old table name * @param string the new table name * @return string */ - function _rename_table($table_name, $new_table_name) + public function _rename_table($table_name, $new_table_name) { - $sql = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name); } } /* End of file cubrid_forge.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ -- cgit v1.2.3-24-g4f1b From 69a6093da35640482a8394ca66686e045304b0e3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 14:04:06 +0200 Subject: Replace array_key_exists() with isset() and ! empty() --- system/database/drivers/cubrid/cubrid_forge.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index ce5aa2098..d277ca394 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -89,13 +89,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge { $attributes = array_change_key_case($attributes, CASE_UPPER); $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"' - .(array_key_exists('NAME', $attributes) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); + .(isset($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); - if (array_key_exists('TYPE', $attributes)) + if ( ! empty($attributes['TYPE'])) { $sql .= ' '.$attributes['TYPE']; - if (array_key_exists('CONSTRAINT', $attributes)) + if (isset($attributes['CONSTRAINT'])) { switch ($attributes['TYPE']) { @@ -118,16 +118,16 @@ class CI_DB_cubrid_forge extends CI_DB_forge { /* As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type. * Will be supported in the next release as a part of MySQL Compatibility. * - if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE) + if (isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) { $sql .= ' UNSIGNED'; } */ - $sql .= (array_key_exists('DEFAULT', $attributes) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') - .((array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') - .((array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') - .((array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); + $sql .= (isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') + .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') + .((isset($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); } // don't add a comma on the end of the last field -- cgit v1.2.3-24-g4f1b From c6953f4077fe3ee394abb37eaa0575527bd013cc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 26 Jan 2012 14:43:16 +0200 Subject: Fix _limit() --- system/database/drivers/cubrid/cubrid_forge.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index d277ca394..4b1c2839a 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -89,13 +89,13 @@ class CI_DB_cubrid_forge extends CI_DB_forge { $attributes = array_change_key_case($attributes, CASE_UPPER); $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"' - .(isset($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); + .( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); if ( ! empty($attributes['TYPE'])) { $sql .= ' '.$attributes['TYPE']; - if (isset($attributes['CONSTRAINT'])) + if ( ! empty($attributes['CONSTRAINT'])) { switch ($attributes['TYPE']) { @@ -125,9 +125,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ $sql .= (isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') - .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') - .((isset($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') - .((isset($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); + .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') + .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') + .(( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); } // don't add a comma on the end of the last field -- cgit v1.2.3-24-g4f1b From 7719a037c4648be714ebe577aa38acba012f7d90 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 27 Jan 2012 21:05:55 +0200 Subject: Switch _process_fields() from private to protected --- system/database/drivers/cubrid/cubrid_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 4b1c2839a..8423180e9 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -70,7 +70,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param mixed the fields * @return string */ - private function _process_fields($fields) + protected function _process_fields($fields) { $current_field_count = 0; $sql = ''; -- cgit v1.2.3-24-g4f1b From 2e430a3f3b160641c36037fbaf92457e0b3bb51e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 12 Feb 2012 23:37:58 +0200 Subject: Added CUBRID DSN string & persistent connections support --- system/database/drivers/cubrid/cubrid_forge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 8423180e9..11143a05f 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -163,7 +163,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } */ - $sql .= $this->db->_escape_identifiers($table).' ('.$this->_process_fields($fields); + $sql .= $this->db->protect_identifiers($table).' ('.$this->_process_fields($fields); // If there is a PK defined if (count($primary_keys) > 0) @@ -203,7 +203,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ public function _drop_table($table) { - return 'DROP TABLE IF EXISTS '.$this->db->_escape_identifiers($table); + return 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 394a3f171c72176d3e31a2562e604a26a703f957 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 15 Feb 2012 14:35:11 +0200 Subject: Add improvements from @CUBRID's implementation --- system/database/drivers/cubrid/cubrid_forge.php | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 11143a05f..5f7985705 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 1.0 + * @since Version 3.0 * @filesource */ @@ -42,8 +42,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ public function _create_database($name) { - // CUBRID does not allow to create a database in SQL. The GUI tools - // have to be used for this purpose. + // CUBRID does not allow to create a database in SQL. GUI or + // command line tools have to be used for this purpose. return FALSE; } @@ -57,8 +57,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ public function _drop_database($name) { - // CUBRID does not allow to drop a database in SQL. The GUI tools - // have to be used for this purpose. + // CUBRID does not allow to drop a database in SQL. GUI or + // command line tools have to be used for this purpose. return FALSE; } @@ -88,7 +88,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"' + $sql .= "\n\t".$this->db->protect_identifiers($field) .( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); if ( ! empty($attributes['TYPE'])) @@ -104,7 +104,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge { case 'numeric': $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; break; - case 'enum': // As of version 8.4.0 CUBRID does not support enum data type + case 'enum': + // Will be supported in the future as part a part of + // MySQL compatibility features. break; case 'set': $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; @@ -115,7 +117,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } } - /* As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type. + /* As of version 8.4.1 CUBRID does not support UNSIGNED INTEGER data type. * Will be supported in the next release as a part of MySQL Compatibility. * if (isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) @@ -156,7 +158,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { $sql = 'CREATE TABLE '; - /* As of version 8.4.0 CUBRID does not support this SQL syntax. + /* As of version 8.4.1 CUBRID does not support this SQL syntax. if ($if_not_exists === TRUE) { $sql .= 'IF NOT EXISTS '; @@ -168,7 +170,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { // If there is a PK defined if (count($primary_keys) > 0) { - $key_name = 'pk_'.$table.'_'.$this->db->protect_identifiers(implode('_', $primary_keys)); + $key_name = $this->db->protect_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; } @@ -178,12 +180,12 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { if (is_array($key)) { - $key_name = $this->db->protect_identifiers(implode('_', $key)); + $key_name = $this->db->protect_identifiers('idx_'.$table.implode('_', $key)); $key = $this->db->protect_identifiers($key); } else { - $key_name = $this->db->protect_identifiers($key); + $key_name = $this->db->protect_identifiers('idx_'.$table.$key); $key = array($key_name); } -- cgit v1.2.3-24-g4f1b From cf63120a60da9485ab1f94bc58b5d62e6b05a0fd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 16 Feb 2012 11:36:28 +0200 Subject: A change in the class descriptions --- system/database/drivers/cubrid/cubrid_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 5f7985705..048a0597b 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com - * @since Version 3.0 + * @since Version 2.1 * @filesource */ -- cgit v1.2.3-24-g4f1b From fead0550fcef5681a8a031433232c03b9cc1218d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:23:06 +0200 Subject: Remove EOF newlines --- system/database/drivers/cubrid/cubrid_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index f0d9804cc..6b8097370 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -254,4 +254,4 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } /* End of file cubrid_forge.php */ -/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ +/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 48a2baf0e288accd206f5da5031d29076e130792 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:09:54 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/database --- system/database/drivers/cubrid/cubrid_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 4e66f81e3..fb9716226 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -193,7 +193,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } -- cgit v1.2.3-24-g4f1b From 5ef194df98294d5427c0e7582ca88b1fc06e1d72 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 01:12:54 +0300 Subject: Resolve formatting differences between DB forge drivers --- system/database/drivers/cubrid/cubrid_forge.php | 45 ++++++++++++++++--------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index fb9716226..1379e6d3a 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -60,8 +60,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge { else { $attributes = array_change_key_case($attributes, CASE_UPPER); - $sql .= "\n\t".$this->db->protect_identifiers($field) - .( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : ''); + + $sql .= "\n\t".$this->db->escape_identifiers($field); + + empty($attributes['NAME']) OR $sql .= $this->db->escape_identifiers($attributes['NAME']).' '; if ( ! empty($attributes['TYPE'])) { @@ -69,7 +71,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { if ( ! empty($attributes['CONSTRAINT'])) { - switch ($attributes['TYPE']) + switch (strtolower($attributes['TYPE'])) { case 'decimal': case 'float': @@ -98,10 +100,23 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } */ - $sql .= (isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '') - .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL') - .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '') - .(( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) ? ' UNIQUE' : ''); + if (isset($attributes['DEFAULT'])) + { + $sql .= " DEFAULT '".$attributes['DEFAULT']."'"; + } + + $sql .= ( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) + ? ' NULL' : ' NOT NULL'; + + if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) + { + $sql .= ' AUTO_INCREMENT'; + } + + if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + { + $sql .= ' UNIQUE'; + } } // don't add a comma on the end of the last field @@ -142,8 +157,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge { // If there is a PK defined if (count($primary_keys) > 0) { - $key_name = $this->db->protect_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); - $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; + $key_name = $this->db->escape_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); + $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->escape_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -152,12 +167,12 @@ class CI_DB_cubrid_forge extends CI_DB_forge { { if (is_array($key)) { - $key_name = $this->db->protect_identifiers('idx_'.$table.implode('_', $key)); - $key = $this->db->protect_identifiers($key); + $key_name = $this->db->escape_identifiers('idx_'.$table.implode('_', $key)); + $key = $this->db->escape_identifiers($key); } else { - $key_name = $this->db->protect_identifiers('idx_'.$table.$key); + $key_name = $this->db->escape_identifiers('idx_'.$table.$key); $key = array($key_name); } @@ -184,16 +199,16 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ protected function _alter_table($alter_type, $table, $fields, $after_field = '') { - $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '; + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' '.$alter_type.' '; // DROP has everything it needs now. if ($alter_type === 'DROP') { - return $sql.$this->db->protect_identifiers($fields); + return $sql.$this->db->escape_identifiers($fields); } return $sql.$this->_process_fields($fields) - .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->escape_identifiers($after_field) : ''); } } -- cgit v1.2.3-24-g4f1b From caa04f15096590261093dff2a8b59f266a1dcaf5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 01:39:20 +0300 Subject: Revert back some escape_identifiers() to proect_identifiers() as the first one can't handle arrays --- system/database/drivers/cubrid/cubrid_forge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 1379e6d3a..8434cd2e2 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -63,7 +63,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { $sql .= "\n\t".$this->db->escape_identifiers($field); - empty($attributes['NAME']) OR $sql .= $this->db->escape_identifiers($attributes['NAME']).' '; + empty($attributes['NAME']) OR $sql .= ' '.$this->db->escape_identifiers($attributes['NAME']).' '; if ( ! empty($attributes['TYPE'])) { @@ -158,7 +158,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { if (count($primary_keys) > 0) { $key_name = $this->db->escape_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); - $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->escape_identifiers($primary_keys)).')'; + $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -168,7 +168,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { if (is_array($key)) { $key_name = $this->db->escape_identifiers('idx_'.$table.implode('_', $key)); - $key = $this->db->escape_identifiers($key); + $key = $this->db->protect_identifiers($key); } else { -- cgit v1.2.3-24-g4f1b From 9637b40ca9e9ac1cdce2b895d3db09848a6eef76 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Jun 2012 15:39:24 +0300 Subject: escape_identifiers() to accept arrays as well --- system/database/drivers/cubrid/cubrid_forge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 8434cd2e2..d328aa241 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -158,7 +158,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { if (count($primary_keys) > 0) { $key_name = $this->db->escape_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); - $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->protect_identifiers($primary_keys)).')'; + $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->escape_identifiers($primary_keys)).')'; } if (is_array($keys) && count($keys) > 0) @@ -168,7 +168,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { if (is_array($key)) { $key_name = $this->db->escape_identifiers('idx_'.$table.implode('_', $key)); - $key = $this->db->protect_identifiers($key); + $key = $this->db->escape_identifiers($key); } else { -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/database/drivers/cubrid/cubrid_forge.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index d328aa241..a7b4efd9a 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -1,4 +1,4 @@ - Date: Fri, 2 Nov 2012 02:04:59 +0200 Subject: [ci skip] DocBlocks for DB drivers' utility classes Partially fixes issue #1295. --- system/database/drivers/cubrid/cubrid_forge.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index a7b4efd9a..33d502137 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -35,13 +35,26 @@ defined('BASEPATH') OR exit('No direct script access allowed'); */ class CI_DB_cubrid_forge extends CI_DB_forge { + /** + * CREATE DATABASE statement + * + * @var string + */ protected $_create_database = FALSE; + + // -------------------------------------------------------------------- + + /** + * DROP DATABASE statement + * + * @var string + */ protected $_drop_database = FALSE; /** * Process Fields * - * @param mixed the fields + * @param mixed $fields * @return string */ protected function _process_fields($fields) -- cgit v1.2.3-24-g4f1b From a287a34c215903d3452023d74149eb5880125715 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Nov 2012 23:19:59 +0200 Subject: Refactored DB Forge - PDO subdrivers are isolated from each other now. - Added compatibility for pretty much all of the features, for every DB platform. - Unified the way that stuff works in general. - Fixes issue #1005. --- system/database/drivers/cubrid/cubrid_forge.php | 214 +++++++++--------------- 1 file changed, 78 insertions(+), 136 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 33d502137..e3f8bc334 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -42,8 +42,6 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ protected $_create_database = FALSE; - // -------------------------------------------------------------------- - /** * DROP DATABASE statement * @@ -52,177 +50,121 @@ class CI_DB_cubrid_forge extends CI_DB_forge { protected $_drop_database = FALSE; /** - * Process Fields + * CREATE TABLE IF statement * - * @param mixed $fields - * @return string + * @var string + */ + protected $_create_table_if = FALSE; + + /** + * UNSIGNED support + * + * @var array */ - protected function _process_fields($fields) + protected $_unsigned = array( + 'SHORT' => 'INTEGER', + 'SMALLINT' => 'INTEGER', + 'INT' => 'BIGINT', + 'INTEGER' => 'BIGINT', + 'BIGINT' => 'NUMERIC', + 'FLOAT' => 'DOUBLE', + 'REAL' => 'DOUBLE' + ); + + // -------------------------------------------------------------------- + + /** + * ALTER TABLE + * + * @param string $alter_type ALTER type + * @param string $table Table name + * @param mixed $field Column definition + * @return string|string[] + */ + protected function _alter_table($alter_type, $table, $field) { - $current_field_count = 0; - $sql = ''; + if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) + { + return parent::_alter_table($alter_type, $table, $field); + } - foreach ($fields as $field => $attributes) + $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table); + $sqls = array(); + for ($i = 0, $c = count($field); $i < $c; $i++) { - // Numeric field names aren't allowed in databases, so if the key is - // numeric, we know it was assigned by PHP and the developer manually - // entered the field information, so we'll simply add it to the list - if (is_numeric($field)) + if ($field[$i]['_literal'] !== FALSE) { - $sql .= "\n\t".$attributes; + $sqls[] = $sql.' CHANGE '.$field[$i]['_literal']; } else { - $attributes = array_change_key_case($attributes, CASE_UPPER); - - $sql .= "\n\t".$this->db->escape_identifiers($field); - - empty($attributes['NAME']) OR $sql .= ' '.$this->db->escape_identifiers($attributes['NAME']).' '; - - if ( ! empty($attributes['TYPE'])) - { - $sql .= ' '.$attributes['TYPE']; - - if ( ! empty($attributes['CONSTRAINT'])) - { - switch (strtolower($attributes['TYPE'])) - { - case 'decimal': - case 'float': - case 'numeric': - $sql .= '('.implode(',', $attributes['CONSTRAINT']).')'; - break; - case 'enum': - // Will be supported in the future as part a part of - // MySQL compatibility features. - break; - case 'set': - $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")'; - break; - default: - $sql .= '('.$attributes['CONSTRAINT'].')'; - } - } - } - - /* As of version 8.4.1 CUBRID does not support UNSIGNED INTEGER data type. - * Will be supported in the next release as a part of MySQL Compatibility. - * - if (isset($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) - { - $sql .= ' UNSIGNED'; - } - */ - - if (isset($attributes['DEFAULT'])) - { - $sql .= " DEFAULT '".$attributes['DEFAULT']."'"; - } - - $sql .= ( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) - ? ' NULL' : ' NOT NULL'; - - if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) - { - $sql .= ' AUTO_INCREMENT'; - } - - if ( ! empty($attributes['UNIQUE']) && $attributes['UNIQUE'] === TRUE) + $sqls[] = $sql.' CHANGE '.$this->_process_column($field[$i]); + if ( ! empty($field[$i]['new_name'])) { - $sql .= ' UNIQUE'; + $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) + .' AS '.$this->db->escape_identifiers($field[$i]['name']); } } - - // don't add a comma on the end of the last field - if (++$current_field_count < count($fields)) - { - $sql .= ','; - } } - return $sql; + return $sqls; } // -------------------------------------------------------------------- /** - * Create Table + * Field attribute TYPE * - * @param string the table name - * @param mixed the fields - * @param mixed primary key(s) - * @param mixed key(s) - * @param bool should 'IF NOT EXISTS' be added to the SQL - * @return bool + * Performs a data type mapping between different databases. + * + * @param array &$attributes + * @return void */ - protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) + protected function _attr_type(&$attributes) { - $sql = 'CREATE TABLE '; - - /* As of version 8.4.1 CUBRID does not support this SQL syntax. - if ($if_not_exists === TRUE) + switch (strtoupper($attributes['TYPE'])) { - $sql .= 'IF NOT EXISTS '; + case 'TINYINT': + $attributes['TYPE'] = 'SMALLINT'; + $attributes['UNSIGNED'] = FALSE; + return; + case 'MEDIUMINT': + $attributes['TYPE'] = 'INTEGER'; + $attributes['UNSIGNED'] = FALSE; + return; + default: return; } - */ - - $sql .= $this->db->escape_identifiers($table).' ('.$this->_process_fields($fields); - - // If there is a PK defined - if (count($primary_keys) > 0) - { - $key_name = $this->db->escape_identifiers('pk_'.$table.'_'.implode('_', $primary_keys)); - $sql .= ",\n\tCONSTRAINT ".$key_name.' PRIMARY KEY('.implode(', ', $this->db->escape_identifiers($primary_keys)).')'; - } - - if (is_array($keys) && count($keys) > 0) - { - foreach ($keys as $key) - { - if (is_array($key)) - { - $key_name = $this->db->escape_identifiers('idx_'.$table.implode('_', $key)); - $key = $this->db->escape_identifiers($key); - } - else - { - $key_name = $this->db->escape_identifiers('idx_'.$table.$key); - $key = array($key_name); - } - - $sql .= ",\n\tKEY ".$key_name.' ('.implode(', ', $key).')'; - } - } - - return $sql."\n);"; } // -------------------------------------------------------------------- /** - * Alter table query - * - * Generates a platform-specific query so that a table can be altered - * Called by add_column(), drop_column(), and column_alter(), + * Process indexes * - * @param string the ALTER type (ADD, DROP, CHANGE) - * @param string the column name - * @param array fields - * @param string the field after which we should add the new field + * @param string $table (ignored) * @return string */ - protected function _alter_table($alter_type, $table, $fields, $after_field = '') + protected function _process_indexes($table = NULL) { - $sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' '.$alter_type.' '; + $sql = ''; - // DROP has everything it needs now. - if ($alter_type === 'DROP') + for ($i = 0, $c = count($this->keys); $i < $c; $i++) { - return $sql.$this->db->escape_identifiers($fields); + if ( ! isset($this->fields[$this->keys[$i]])) + { + unset($this->keys[$i]); + continue; + } + + is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]); + + $sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i])) + .' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')'; } - return $sql.$this->_process_fields($fields) - .($after_field !== '' ? ' AFTER '.$this->db->escape_identifiers($after_field) : ''); + $this->keys = array(); + + return $sql; } } -- cgit v1.2.3-24-g4f1b From b0a97c100f5e7edc5e21ec7d07f768cd3b5618da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Nov 2012 13:58:53 +0200 Subject: Fix DBForge index creation on MySQL and CUBRID --- system/database/drivers/cubrid/cubrid_forge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index e3f8bc334..86a41e57b 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -42,6 +42,16 @@ class CI_DB_cubrid_forge extends CI_DB_forge { */ protected $_create_database = FALSE; + /** + * CREATE TABLE keys flag + * + * Whether table keys are created from within the + * CREATE TABLE statement. + * + * @var bool + */ + protected $_create_table_keys = TRUE; + /** * DROP DATABASE statement * -- cgit v1.2.3-24-g4f1b From b67277b8063b0e6aab051ce269194255ef83e808 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 12 Nov 2012 12:51:14 +0200 Subject: Bring back the AFTER clause for DB Forge add_column() (it was temporarily removed due to multiple inconsistencies with other drivers) This commit also fixes issue #1988. Also added support for the FIRST clause (again, MySQL and CUBRID only). --- system/database/drivers/cubrid/cubrid_forge.php | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 86a41e57b..05762ba5a 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -122,6 +122,35 @@ class CI_DB_cubrid_forge extends CI_DB_forge { // -------------------------------------------------------------------- + /** + * Process column + * + * @param array $field + * @return string + */ + protected function _process_column($field) + { + $extra_clause = isset($field['after']) + ? ' AFTER '.$this->db->escape_identifiers($field['after']) : ''; + + if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE) + { + $extra_clause = ' FIRST'; + } + + return $this->db->escape_identifiers($field['name']) + .(empty($field['new_name']) ? '' : $this->db->escape_identifiers($field['new_name'])) + .' '.$field['type'].$field['length'] + .$field['unsigned'] + .$field['null'] + .$field['default'] + .$field['auto_increment'] + .$field['unique'] + .$extra_clause; + } + + // -------------------------------------------------------------------- + /** * Field attribute TYPE * -- cgit v1.2.3-24-g4f1b From 7ade8b7944d10f4fd1583789309cf003a3eac6f7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 22 Nov 2012 13:12:22 +0200 Subject: Fix modify_column() issues (#2020) --- system/database/drivers/cubrid/cubrid_forge.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 05762ba5a..9a7cdb805 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -108,12 +108,8 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } else { - $sqls[] = $sql.' CHANGE '.$this->_process_column($field[$i]); - if ( ! empty($field[$i]['new_name'])) - { - $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name']) - .' AS '.$this->db->escape_identifiers($field[$i]['name']); - } + $alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE '; + $sqls[] = $sql.$alter_type$this->_process_column($field[$i]); } } @@ -139,7 +135,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } return $this->db->escape_identifiers($field['name']) - .(empty($field['new_name']) ? '' : $this->db->escape_identifiers($field['new_name'])) + .(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name'])) .' '.$field['type'].$field['length'] .$field['unsigned'] .$field['null'] -- cgit v1.2.3-24-g4f1b From 3545102a83a70a42876148037bec05f4bb32913e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Nov 2012 17:20:04 +0200 Subject: Fix #2027 --- system/database/drivers/cubrid/cubrid_forge.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'system/database/drivers/cubrid/cubrid_forge.php') diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 9a7cdb805..2a737c5ed 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -179,13 +179,24 @@ class CI_DB_cubrid_forge extends CI_DB_forge { * @param string $table (ignored) * @return string */ - protected function _process_indexes($table = NULL) + protected function _process_indexes($table) { $sql = ''; for ($i = 0, $c = count($this->keys); $i < $c; $i++) { - if ( ! isset($this->fields[$this->keys[$i]])) + if (is_array($this->keys[$i])) + { + for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++) + { + if ( ! isset($this->fields[$this->keys[$i][$i2]])) + { + unset($this->keys[$i][$i2]); + continue; + } + } + } + elseif ( ! isset($this->fields[$this->keys[$i]])) { unset($this->keys[$i]); continue; -- cgit v1.2.3-24-g4f1b