PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #8878

Simplify autoExecute() behaviour to select some columns.

Details

Request #8878Simplify autoExecute() behaviour to select some columns.
Submitted2006-10-06 23:16 UTC
Fromsimon at ruderich dot com
Assigneddavidc
StatusClosed
PackageMDB2
PHP VersionIrrelevant
OSMac OS X 10.4
Roadmaps(Not assigned)

Comments

[2006-10-06 23:16 UTC] simon at ruderich dot com

Description:
------------
I tried to get autoExecute() from MDB2 Extended to return all columns, but I only
got an error because of a wrong Query: "SELECT FROM". Now I looked up in CVS and
noticed that this bug is already fixed.
It would be nice if you make an official release to fix this bug which is quite a
problem (for me).

But there is still a problem if I want to select only some columns.
It would be better to use autoExecute() this way:
autoExecute( 'table', array( 'column_one', 'column_two', ... ),
MDB2_AUTOQUERY_SELECT, 'where condition', null, true, MDB2_PREPARE_RESULT )
So you only have to specify the columns and not their types which is not necessary
with SELECT or UPDATE queries either.
Another possibility would be to allow the use of the last parameter of autoExecute
() $result_types as flat array of column names without the type as value.
I added a patch for my first idea. It can be run on the CVS version 1.54 of MDB2/
Extended.php. This patch would also not interfere with the "old" use of
autoExecute() with SELECTs where the last parameter is used.

I hope you could add this feature to MDB2 Extended.
Thanks for your great work with MDB2,
Simon

Test script:
---------------
--- Extended.php (CVS 1.54) 2006-10-07 00:36:33.000000000 +0200
+++ Extended.php (my patch) 2006-10-07 01:06:05.000000000 +0200
@@ -135,6 +135,8 @@
if ($mode == MDB2_AUTOQUERY_SELECT) {
if (is_array($result_types)) {
$keys = array_keys($result_types);
+ } elseif (!empty( $fields_values)) {
+ $keys = $fields_values;
} else {
$keys = array();
}