Home » Database » MDB2_Driver_mssql » Bug #8373
ALTER TABLE bug when adding more than 1 column
Details
| Submitted | 2006-08-07 13:11 UTC |
|---|---|
| From | kaiser at unisolution dot de |
| Assigned | lsmith |
| Status | Closed |
| Package | MDB2_Driver_mssql |
| PHP Version | 4.3.8 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-08-07 13:11 UTC] kaiser at unisolution dot de
Description:
------------
There is a bug in the alterTable function. It works fine when adding only one column, but doesn´t work for more than 1 column. Problem is that it produces a sql statement like this:
ALTER TABLE abc ADD column1 integer, ADD column2 integer
but that doesn´t work in MS SQL, it should be:
ALTER TABLE abc ADD column1 integer, column2 integer
I fixed this bug by modifing the alterTable function in /Driver/Manager/mssql.php
I replaced (starting from line 227)
foreach ($changes['add'] as $field_name => $field) {
if ($query) {
$query.= ', ';
}
$query.= 'ADD '.$db->getDeclaration($field['type'], $field_name, $field);
}
by
foreach ($changes['add'] as $field_name => $field) {
if ($query) {
$query.= ', ';
}
else {
$query.= 'ADD ';
}
$query.= $db->getDeclaration($field['type'], $field_name, $field);
}
and now it seems to work correctly ...