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 » MDB_QueryTool » Bug #9130

setOrder doubles name of table

Details

Submitted2006-10-22 03:16 UTC
Frommjjareo at gmail dot com
Assignedquipo
StatusClosed
PackageMDB_QueryTool
PHP VersionIrrelevant
OSAll
Roadmaps(Not assigned)

Comments

[2006-10-22 03:16 UTC] mjjareo at gmail dot com

Description:
------------
If one of the columns of a table has the same name as the name of the table, then then _buildOrder returns "tablename.tablename.orderColumnName". This causes the query to fail.

A quick inspection of the code shows that this is occurring because preg_replace will prepend the table name twice.

This bug looks like it will occur in other places where the column name is being transformed to tablename.columnname.

Test script:
---------------
You need a table that has a column whose name is the same as the table name.

class QuestionDAO extends MDB_QueryTool
{
$table = "question";

public function do()
{
$this->setOrder("position");
}
}

Expected result:
----------------
the query should be....

select * from question order by question.position;

Actual result:
--------------
but is...

select * from question order by question.question.position;