summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Flower <zach@ninjaninja.net>2014-11-03 18:42:57 +0100
committerZachary Flower <zach@ninjaninja.net>2014-11-03 18:42:57 +0100
commite4b10bf0ad59049ed78ed9cfc5f708188f3cd442 (patch)
tree1473fb43fa28839a47e02ba36574633fe68d2fbb
parent12ee7a1a74e45b1369876ea945ae3347da046087 (diff)
Move MySQL comments to MySQL forge classes only
-rw-r--r--system/database/DB_forge.php39
-rw-r--r--system/database/drivers/mysql/mysql_forge.php4
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php4
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php4
4 files changed, 15 insertions, 36 deletions
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 0317489f6..85505ce41 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -156,13 +156,6 @@ abstract class CI_DB_forge {
*/
protected $_default = ' DEFAULT ';
- /**
- * COMMENT value representation in CREATE/ALTER TABLE statements
- *
- * @var string
- */
- protected $_comment = ' COMMENT ';
-
// --------------------------------------------------------------------
/**
@@ -777,7 +770,6 @@ abstract class CI_DB_forge {
'unique' => '',
'default' => '',
'auto_increment' => '',
- 'comment' => '',
'_literal' => FALSE
);
@@ -815,7 +807,11 @@ abstract class CI_DB_forge {
$this->_attr_auto_increment($attributes, $field);
$this->_attr_unique($attributes, $field);
- $this->_attr_comment($attributes, $field);
+
+ if (isset($attributes['COMMENT']))
+ {
+ $field['comment'] = $this->db->escape($attributes['COMMENT']);
+ }
if (isset($attributes['TYPE']) && ! empty($attributes['CONSTRAINT']))
{
@@ -858,8 +854,7 @@ abstract class CI_DB_forge {
.$field['default']
.$field['null']
.$field['auto_increment']
- .$field['unique']
- .$field['comment'];
+ .$field['unique'];
}
// --------------------------------------------------------------------
@@ -997,28 +992,6 @@ abstract class CI_DB_forge {
// --------------------------------------------------------------------
/**
- * Field attribute COMMENT
- *
- * @param array &$attributes
- * @param array &$field
- * @return void
- */
- protected function _attr_comment(&$attributes, &$field)
- {
- if ($this->_comment === FALSE)
- {
- return;
- }
-
- if (!empty($attributes['COMMENT']))
- {
- $field['comment'] = $this->_default.$this->db->escape($attributes['COMMENT']);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
* Process primary keys
*
* @param string $table Table name
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index ee89e1d80..282e2d1d8 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -185,6 +185,8 @@ class CI_DB_mysql_forge extends CI_DB_forge {
$extra_clause = ' FIRST';
}
+ $comment_clause = isset($field['comment']) ? ' COMMENT ' . $field['comment'] : '';
+
return $this->db->escape_identifiers($field['name'])
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
@@ -193,7 +195,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
.$field['default']
.$field['auto_increment']
.$field['unique']
- .$field['comment']
+ .$comment_clause
.$extra_clause;
}
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index e37bd1b80..38f624909 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -187,6 +187,8 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
$extra_clause = ' FIRST';
}
+ $comment_clause = isset($field['comment']) ? ' COMMENT ' . $field['comment'] : '';
+
return $this->db->escape_identifiers($field['name'])
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
@@ -195,7 +197,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
.$field['default']
.$field['auto_increment']
.$field['unique']
- .$field['comment']
+ .$comment_clause
.$extra_clause;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
index 2152dea30..2e988c3f5 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_forge.php
@@ -199,6 +199,8 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
$extra_clause = ' FIRST';
}
+ $comment_clause = isset($field['comment']) ? ' COMMENT ' . $field['comment'] : '';
+
return $this->db->escape_identifiers($field['name'])
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
.' '.$field['type'].$field['length']
@@ -207,7 +209,7 @@ class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
.$field['default']
.$field['auto_increment']
.$field['unique']
- .$field['comment']
+ .$comment_clause
.$extra_clause;
}