PEAR is archived and read-only

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

Home » Structures » Structures_DataGrid_DataSource_MDB2 » Bug #9871

Field names like SPEED_LIMIT truncated

Details

Submitted2007-01-18 19:00 UTC
Frommichael dot mauch at gmx dot de
Assignedolivierg
StatusClosed
PackageStructures_DataGrid_DataSource_MDB2
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2007-01-18 19:00 UTC] michael dot mauch at gmx dot de

Description:
------------
A query like

select SPEED_LIMIT
from MY_TABLE

is truncated at LIMIT.

The culprit is in Structures/DataGrid/DataSource/MDB2.php:

// drop LIMIT statement
$query = preg_replace('#LIMIT\s.*$#isD', '', $query);

Test script:
---------------
SQL to create a test table:

create table xxx_test (speed_limit integer);
insert into xxx_test values(100);
commit;

<?php
require 'Structures/DataGrid.php';
$datagrid =& new Structures_DataGrid();
require 'sql_user_and_password';
$options = array('dsn' => "mysql://$sql_user:$sql_password@localhost/test");
$test = $datagrid->bind('select SPEED_LIMIT from XXX_TEST', $options);
if (PEAR::isError($test)) {
echo $test->getMessage(),' | ',$test->getUserInfo();
}
$test = $datagrid->render();
?>

Expected result:
----------------
The query should work and field names should not be truncated.
It works with the above line changed to:

$query = preg_replace('#\sLIMIT\s.*$#isD', ' ', $query);

(The '\s' before LIMIT is new, and the replacement is now a space instead of an empty string.)

Actual result:
--------------
MDB2 Error: no such field | _doQuery: [Error message: Could not execute statement] [Last executed query: select SPEED_] [Native code: 1054] [Native message: Unknown column 'SPEED_' in 'field list']

[2007-01-19 10:35 UTC] olivierg at php dot net

Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/Structures_DataGrid_DataSource_MDB2