Skip to content

Commit

Permalink
cubrid_driver: Added $_escape_char like in MySQL.
Browse files Browse the repository at this point in the history
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
kadishmal committed Feb 10, 2012
1 parent 4a1a776 commit 56f0353
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
5 changes: 3 additions & 2 deletions system/database/drivers/cubrid/cubrid_driver.php
Expand Up @@ -36,8 +36,9 @@ class CI_DB_cubrid_driver extends CI_DB {

var $dbdriver = 'cubrid';

// The character used for escaping - no need in CUBRID
var $_escape_char = '';
// The character used for escaping. Using MySQL style.
// Also supports [] like in MSSQL, or "" like in Oracle.
protected $_escape_char = '`';

// clause and character used for LIKE escape sequences - not used in CUBRID
var $_like_escape_str = '';
Expand Down
32 changes: 17 additions & 15 deletions system/database/drivers/cubrid/cubrid_forge.php
Expand Up @@ -9,7 +9,7 @@
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @since Version 2.1
* @filesource
*/

Expand All @@ -34,7 +34,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
function _create_database($name)
{
// CUBRID does not allow to create a database in SQL. The GUI tools
// have to be used for this purpose.
// or command line "cubrid createdb" utility have to be used for this purpose.
return FALSE;
}

Expand All @@ -50,7 +50,7 @@ function _create_database($name)
function _drop_database($name)
{
// CUBRID does not allow to drop a database in SQL. The GUI tools
// have to be used for this purpose.
// or command line "cubbrid deletedb" utility have to be used for this purpose.
return FALSE;
}

Expand Down Expand Up @@ -81,7 +81,7 @@ function _process_fields($fields)
{
$attributes = array_change_key_case($attributes, CASE_UPPER);

$sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\"";
$sql .= "\n\t" . $this->db->_protect_identifiers($field) . "";

if (array_key_exists('NAME', $attributes))
{
Expand All @@ -101,9 +101,9 @@ function _process_fields($fields)
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': // enum data type will be supported in the
// next release as a part of MySQL Compatibility.
break;
case 'set':
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
break;
Expand All @@ -116,7 +116,7 @@ function _process_fields($fields)
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.
// 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.
}

Expand Down Expand Up @@ -175,7 +175,7 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
if ($if_not_exists === TRUE)
{
//$sql .= 'IF NOT EXISTS ';
// 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.
}

$sql .= $this->db->_escape_identifiers($table)." (";
Expand All @@ -185,9 +185,11 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
// If there is a PK defined
if (count($primary_keys) > 0)
{
$key_name = "pk_" . $table . "_" .
$this->db->_protect_identifiers(implode('_', $primary_keys));

// Index names in CUBRID are unique per database, So it is recommended to indicate
// in any index name the name of the table the index belongs to. This will assure
// that this index is unique in the entire database. The suggested form is
// pk_tableName_col1Name_col2Name_etc:
$key_name = $this->db->_protect_identifiers("pk_" . $table . "_" . implode('_', $primary_keys));
$primary_keys = $this->db->_protect_identifiers($primary_keys);
$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
}
Expand All @@ -198,16 +200,16 @@ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
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);
}

$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
$sql .= ",\n\tKEY {$key_name} (" . implode(', ', $key) . ")";
}
}

Expand Down

0 comments on commit 56f0353

Please sign in to comment.