summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-01-05 17:32:57 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-01-05 17:32:57 +0100
commit27324cd6ae2b076d3346e3585f312f7a61a5a897 (patch)
treeaae9c10310f7a573fd75ecdc0ac6dcf6c6837b21
parent5c561805bd9ae6a4ad5d202277c34a879617b683 (diff)
Use arrays in DBForge for constraint for things like decimal, float, numeric, enum and set.
-rw-r--r--system/database/drivers/mysql/mysql_forge.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 8faf69550..35845d6af 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -87,11 +87,26 @@ class CI_DB_mysql_forge extends CI_DB_forge {
if (array_key_exists('TYPE', $attributes))
{
$sql .= ' '.$attributes['TYPE'];
- }
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ switch ($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'].')';
+ }
+ }
}
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)