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 » DB » Bug #4052

DB_mysqli::tableInfo() doesn't work for "special" table names

Details

Submitted2005-04-04 13:00 UTC
Frompear dot php dot net at chsc dot dk
Assigneddanielc
StatusWont fix
PackageDB
PHP Version5.0.3
OSLinux
Roadmaps(Not assigned)

Comments

[2005-04-04 13:00 UTC] pear dot php dot net at chsc dot dk

Description:
------------
When $db is a DB_mysqli, the following does not work when $table is a reserved SQL word, e.g. "limit".

$db->tableInfo("limit");

In DB/mysqli.php line 825 the SQL should read

"SELECT * FROM `$result` LIMIT 0"

instead of

"SELECT * FROM $result LIMIT 0"

[2005-04-04 13:02 UTC] pear dot php dot net at chsc dot dk

Summary made more accurate

[2005-04-04 13:04 UTC] smith at backendmedia dot com

I guess calling quoteIdentifier() wouldnt hurt.

[2005-04-04 15:50 UTC] pear dot php dot net at chsc dot dk

Yes, using reserved words for table names is asking for trouble. But the database design is not always under your control.

A way to solve this problem in most cases is to only add quotes when the table name does not match /^\w+$/ (or something like that).