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 #9734

problem with preg_replace statement in _buildGroup

Details

Submitted2007-01-04 17:14 UTC
Frombbaumer at nymets dot com
Assignedquipo
StatusClosed
PackageMDB_QueryTool
PHP Version5.2.0
OSWin XP
Roadmaps(Not assigned)

Comments

[2007-01-04 17:14 UTC] bbaumer at nymets dot com

Description:
------------
The "preg_replace" statement on line 1939 of MDB/QueryTool/Query.php does not work as expected. Specifically, this statement will add extraneous table names to the fields in the GROUP BY statement of a query, if the name of the grouped upon field appears as a column name in the table that is being searched.

Test script:
---------------
<?php
require_once "MDB/QueryTool.php";
$dsn='mysqli://user:pass@localhost/mysql';
$query=new MDB_QueryTool($dsn,NULL,2);
$query->setSelect("host, count(distinct user) as NumUsers");
$query->setTable("user");
$query->setGroup("host");
echo $query->getGroup();
echo "<br>";
print_r($query->metadata());
echo $query->getQueryString();
echo "<br>";
print_r($query->execute());
?>

Expected result:
----------------
host
SELECT host, count(distinct user) as NumUsers FROM user GROUP BY user.host

Actual result:
--------------
host
SELECT host, count(distinct user) as NumUsers FROM user GROUP BY user.user.host