PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » MDB2_Driver_mssql » Bug #8373

ALTER TABLE bug when adding more than 1 column

Details

Submitted2006-08-07 13:11 UTC
Fromkaiser at unisolution dot de
Assignedlsmith
StatusClosed
PackageMDB2_Driver_mssql
PHP Version4.3.8
OSLinux
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 ...