summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli/mysqli_forge.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-20 13:49:56 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-20 13:49:56 +0100
commit87230286b2948cf580e21f426824a974210d7595 (patch)
tree3f0098f4f8b65ff61d60a333351d847387670596 /system/database/drivers/mysqli/mysqli_forge.php
parent5e18e891a14400a96f9b4af36925457b79b62005 (diff)
parent6ea625e7f31b65838f1829408d37ac26009c79bc (diff)
Merge upstream branch
Diffstat (limited to 'system/database/drivers/mysqli/mysqli_forge.php')
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php31
1 files changed, 27 insertions, 4 deletions
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 744525f02..9cb1a0c70 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_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
*
@@ -86,9 +86,32 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '')
- .( ! empty($attributes['TYPE']) ? ' '.$attributes['TYPE'] : '')
- .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
- .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ ;
+
+ 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':
+ case 'set':
+ $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
+ break;
+ default:
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+ }
+ }
+
+ $sql .= (( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
.(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' : '');