PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » Translation2 » Bug #2153

Translation2_Admin_Container_db can't alter table, only create new ones

Details

Submitted2004-08-18 01:59 UTC
Fromesm at baseclass dot modulweb dot dk
Assignedquipo
StatusClosed
PackageTranslation2
PHP Version4.3.8
OSWinn2k / IIS
Roadmaps(Not assigned)

Comments

[2004-08-18 01:59 UTC] esm at baseclass dot modulweb dot dk

Description:
------------
On line 71 in method createNewLang (Admin/Container/DB.php)

This is the code that checks if an existing table should be altered (rather than a new table created):

if (in_array($this->options['strings_tables'][$langID], $res)) {
//table exists
$query = sprintf('ALTER TABLE %s ADD COLUMN %s',
$this->options['strings_tables'][$langID],
$lang_col
);
} else ... etc.....

This does not work for two reasons:

1. The result returned by

$res = $this->query('SHOW TABLES', 'getAll');

is a multidimensional array like this:

Array
(
[0] => Array
(
[0] => table1
)

[1] => Array
(
[0] => table2
)

etc....

The php function in_array() cannot search arrays recursively. Thus the check

if (in_array($this->options['strings_tables'][$langID], $res))

will ALWAYS return false.

2. The query created to ALTER the table will never be valid

$query = sprintf('ALTER TABLE %s ADD COLUMN %s',

will end up something like this:

ALTER TABLE i18n ADD COLUMN en

Which is invalid SQL (no column properties defined)

[2004-08-20 18:16 UTC] esm at baseclass dot modulweb dot dk

The version stamp of my Admin/Container/DB.php

$Id: db.php,v 1.8 2004/04/19 14:58:47 quipo Exp $