Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Request #8878 Simplify autoExecute() behaviour to select some columns.
Submitted: 2006-10-06 23:16 UTC
From: simon at ruderich dot com Assigned: davidc
Status: Closed Package: MDB2 (version CVS)
PHP Version: Irrelevant OS: Mac OS X 10.4
Roadmaps: (Not assigned)    
Subscription  


 [2006-10-06 23:16 UTC] simon at ruderich dot com (Simon Ruderich)
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(); }

Comments

 [2006-10-07 00:33 UTC] davidc (David Coallier)
This seems rather simple and working. I will execute more tests tonight on different rdbms and then I'll apply the patch if it works well. Thanks!
 [2006-10-09 01:08 UTC] davidc (David Coallier)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.