Home » Database » MDB_QueryTool » Bug #9734
problem with preg_replace statement in _buildGroup
Details
| Submitted | 2007-01-04 17:14 UTC |
|---|---|
| From | bbaumer at nymets dot com |
| Assigned | quipo |
| Status | Closed |
| Package | MDB_QueryTool |
| PHP Version | 5.2.0 |
| OS | Win 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