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)    
Subscription  


 [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

Comments

 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!