Fix MSSQL ALTER TABLE ADD statement
An improved version of PR #2329
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 53cdd53..d52029e 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -680,8 +680,12 @@
return $sql.'DROP COLUMN '.$this->db->escape_identifiers($field);
}
+ $sql .= ($alter_type === 'ADD')
+ ? 'ADD '
+ : $alter_type.' COLUMN ';
+
$sqls = array();
- for ($i = 0, $c = count($field), $sql .= $alter_type.' COLUMN '; $i < $c; $i++)
+ for ($i = 0, $c = count($field); $i < $c; $i++)
{
$sqls[] = $sql
.($field[$i]['_literal'] !== FALSE ? $field[$i]['_literal'] : $this->_process_column($field[$i]));