Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

cubrid_driver: Added $_escape_char like in MySQL.

cubrid_forge: Updated the version number of CodeInginer since which CUBRID support is available. Updated comments. Removed explicite quotes from _process_fields() and _create_table() functions since $_escape_char is set in cubrid_driver.php which is used by default in _protect_identifiers().
  • Loading branch information...
commit 56f035392d2f8eb7d8ee7e0ea475da13a1919dcb 1 parent 4a1a776
Esen Sagynov authored
5  system/database/drivers/cubrid/cubrid_driver.php
@@ -36,8 +36,9 @@ class CI_DB_cubrid_driver extends CI_DB {
36 36
 
37 37
 	var $dbdriver = 'cubrid';
38 38
 
39  
-	// The character used for escaping - no need in CUBRID
40  
-	var	$_escape_char = '';
  39
+	// The character used for escaping. Using MySQL style.
  40
+    // Also supports [] like in MSSQL, or "" like in Oracle.
  41
+	protected $_escape_char = '`';
41 42
 
42 43
 	// clause and character used for LIKE escape sequences - not used in CUBRID
43 44
 	var $_like_escape_str = '';
32  system/database/drivers/cubrid/cubrid_forge.php
@@ -9,7 +9,7 @@
9 9
  * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
10 10
  * @license		http://codeigniter.com/user_guide/license.html
11 11
  * @link		http://codeigniter.com
12  
- * @since		Version 1.0
  12
+ * @since		Version 2.1
13 13
  * @filesource
14 14
  */
15 15
 
@@ -34,7 +34,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
34 34
 	function _create_database($name)
35 35
 	{
36 36
 		// CUBRID does not allow to create a database in SQL. The GUI tools
37  
-		// have to be used for this purpose.
  37
+		// or command line "cubrid createdb" utility have to be used for this purpose.
38 38
 		return FALSE;
39 39
 	}
40 40
 
@@ -50,7 +50,7 @@ function _create_database($name)
50 50
 	function _drop_database($name)
51 51
 	{
52 52
 		// CUBRID does not allow to drop a database in SQL. The GUI tools
53  
-		// have to be used for this purpose.
  53
+		// or command line "cubbrid deletedb" utility have to be used for this purpose.
54 54
 		return FALSE;
55 55
 	}
56 56
 
@@ -81,7 +81,7 @@ function _process_fields($fields)
81 81
 			{
82 82
 				$attributes = array_change_key_case($attributes, CASE_UPPER);
83 83
 
84  
-				$sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\"";
  84
+				$sql .= "\n\t" . $this->db->_protect_identifiers($field) . "";
85 85
 
86 86
 				if (array_key_exists('NAME', $attributes))
87 87
 				{
@@ -101,9 +101,9 @@ function _process_fields($fields)
101 101
 							case 'numeric':
102 102
 								$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
103 103
 								break;
104  
-							case 'enum': 	// As of version 8.4.0 CUBRID does not support
105  
-											// enum data type.
106  
-											break;
  104
+							case 'enum': 	// enum data type will be supported in the
  105
+                                            // next release as a part of MySQL Compatibility.
  106
+                                break;
107 107
 							case 'set':
108 108
 								$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
109 109
 								break;
@@ -116,7 +116,7 @@ function _process_fields($fields)
116 116
 				if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
117 117
 				{
118 118
 					//$sql .= ' UNSIGNED';
119  
-					// As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
  119
+					// As of version 8.4.1 CUBRID does not support UNSIGNED INTEGER data type.
120 120
 					// Will be supported in the next release as a part of MySQL Compatibility.
121 121
 				}
122 122
 
@@ -175,7 +175,7 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
175 175
 		if ($if_not_exists === TRUE)
176 176
 		{
177 177
 			//$sql .= 'IF NOT EXISTS ';
178  
-			// As of version 8.4.0 CUBRID does not support this SQL syntax.
  178
+			// As of version 8.4.1 CUBRID does not support this SQL syntax.
179 179
 		}
180 180
 
181 181
 		$sql .= $this->db->_escape_identifiers($table)." (";
@@ -185,9 +185,11 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
185 185
 		// If there is a PK defined
186 186
 		if (count($primary_keys) > 0)
187 187
 		{
188  
-			$key_name = "pk_" . $table . "_" .
189  
-				$this->db->_protect_identifiers(implode('_', $primary_keys));
190  
-			
  188
+            // Index names in CUBRID are unique per database, So it is recommended to indicate
  189
+            // in any index name the name of the table the index belongs to. This will assure
  190
+            // that this index is unique in the entire database. The suggested form is
  191
+            // pk_tableName_col1Name_col2Name_etc:
  192
+			$key_name = $this->db->_protect_identifiers("pk_" . $table . "_" . implode('_', $primary_keys));
191 193
 			$primary_keys = $this->db->_protect_identifiers($primary_keys);
192 194
 			$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
193 195
 		}
@@ -198,16 +200,16 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
198 200
 			{
199 201
 				if (is_array($key))
200 202
 				{
201  
-					$key_name = $this->db->_protect_identifiers(implode('_', $key));
  203
+					$key_name = $this->db->_protect_identifiers("idx_" . $table . "_" . implode('_', $key));
202 204
 					$key = $this->db->_protect_identifiers($key);
203 205
 				}
204 206
 				else
205 207
 				{
206  
-					$key_name = $this->db->_protect_identifiers($key);
  208
+					$key_name = $this->db->_protect_identifiers("idx_" . $table . "_" . $key);
207 209
 					$key = array($key_name);
208 210
 				}
209 211
 				
210  
-				$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
  212
+				$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
211 213
 			}
212 214
 		}
213 215
 

0 notes on commit 56f0353

Please sign in to comment.
Something went wrong with that request. Please try again.