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

Bug #8734 Wrong use of list()
Submitted: 2006-09-19 10:07 UTC
From: chrismontijn at yahoo dot com Assigned: quipo
Status: Closed Package: Translation2 (version 2.0.0beta11)
PHP Version: 4.4.2 OS: Windows XP
Roadmaps: (Not assigned)    

 [2006-09-19 10:07 UTC] chrismontijn at yahoo dot com (chris)
Description: ------------ When using an existing db connection, with fetchmode set to associative, to instantiate an translation2 object at least one (didn't check further) list() function is not working properly. For example in the MDB2.php container on line 217 in function getPage() there is a list() not working properly, because the indices of the result array are tablecolumnnames instead of numbers (starting from zero). Test script: --------------- $dsn = 'somedsn'; $db =& MDB2::connect($dsn); // !This is where it goes wrong $db->setFetchmode(MDB2_FETCHMODE_ASSOC); // instantiate translation2 with this database connection $tr =& Translation2::factory($dbdriver, &$db, $TR_options); $tr->setLang('somelang'); $tr =& $tr->getDecorator('CacheMemory'); $tr->setPageID('someGroup'); $tr->get('somestr'); Expected result: ---------------- I expect to see no notices about undefined offsets. Actual result: -------------- When display notices are on in php.ini page shows following errors: Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\pear\Translation2\Container\mdb2.php on line 217 Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\pear\Translation2\Container\mdb2.php on line 217


 [2006-09-19 10:26 UTC] chrismontijn at yahoo dot com
A simple solution is to change line 217 in container/mdb2.php while (list($key, $value) = $res->fetchRow()) { to while (list($key, $value) = $res->fetchRow(MDB2_FETCHMODE_ORDERED)) {
 [2006-09-19 10:34 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the 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.