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

Feature Request - get SELECT as assoc array?

Details

Request #9872Feature Request - get SELECT as assoc array?
Submitted2007-01-18 20:40 UTC
Frombbaumer at nymets dot com
Assignedquipo
StatusWont fix
PackageMDB_QueryTool
PHP VersionIrrelevant
OSWin XP
Roadmaps(Not assigned)

Comments

[2007-01-18 20:40 UTC] bbaumer at nymets dot com

Description:
------------
Would it be possible to have a function that will return the SELECT string parsed into an associative array, with the field names as the indices? A lot of the work that I do involves calculating totals at the bottom of a result set. This would make this a lot easier.

I think this could be accomplished with a single instance of preg_split().

It could work something like this:

Test script:
---------------
$query->setSelect("id, concat(namelast,', ',namefirst) as Name, sum(h)/sum(ab) as AVG");
...
print_r($query->getSelectAsArray());

$total_query=clone $query;
$total_select=$query->getSelectAsArray();
$total_select['Name']="'Totals'";
$total_query->setSelect($total_select);

print_r($total_query->getSelectAsArray());

Expected result:
----------------
Array
(
[id] => id,
[Name] => concat(namelast,', ',namefirst)
[AVG] => sum(h)/sum(ab)
)

Array
(
[id] => id,
[Name] => 'Totals'
[AVG] => sum(h)/sum(ab)
)

[2007-01-22 18:49 UTC] bbaumer at nymets dot com

I could if all I wanted was the field names, but I also want the field definitions, since that is what I want to change. The idea is that I want to run essentially the same query, but change one of the field definitions.