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

Request #8060 HTML_QuickForm_select -> loadDbResult Support MDB2
Submitted: 2006-06-28 16:47 UTC
From: dvilches at gmail dot com Assigned:
Status: Wont fix Package: HTML_QuickForm2 (version 3.2.6)
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2012-04-08 17:16 UTC
Package:
Bug Type:
Summary:
From: dvilches at gmail dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-06-28 16:47 UTC] dvilches at gmail dot com (dvilches)
Description: ------------ I changed the method loadDbResult in HTML_QuickForm_select. Test script: --------------- require_once 'MDB2.php'; $dsn = array('phptype' => DB_PHPTYPE, 'username' => DB_USER, 'password' => DB_PWD, 'hostspec' => DB_HOST, 'database' => DB_DATABASE, ); $db = MDB2::factory($dsn); if (Pear::isError($db)){ die($db->getMessage()); } $db->setFetchMode(MDB2_FETCHMODE_ASSOC); $sql = "Select table_id, descrip From table"; $element = &HTML_QuickForm::createElement('select', 'table_id', 'Descrip'); $result = $db->query($sql); $element->addOption('',''); $element->loadDbResult($result, 'descrip', 'table_id'); $element->toHtml(); The change of this method is: if (!is_object($result) || !is_a($result, 'db_result')) { .... by if (!is_object($result) || (!is_a($result, 'db_result') && !is_a($result, 'mdb2_result'))) { ... And works for me... Expected result: ---------------- <select name="table_id"> <option value=""></option> <option value="1" selected="selected">Descrip 1</option> <option value="2">Descrip 2</option> <option value="3">Descrip 3</option> </select> Actual result: -------------- <select name="table_id"> <option value=""></option> </select>

Comments

 [2006-07-12 11:47 UTC] dvilches at gmail dot com
I changed the bug type for this item.
 [2006-10-06 15:45 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!
 [2006-11-10 11:34 UTC] buye at libero dot it (Carlo Busetto)
Also changed this code in method loadDbResult for supporting MDB2: function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null) { if (!is_object($result) || !is_a($result, 'db_result') && !is_a($result, 'mdb2_result')) { return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result'); } if (isset($values)) { $this->setValue($values); } if (is_a($result, 'db_result')) { $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED; } else if (is_a($result, 'mdb2_result')) { $fetchMode = ($textCol && $valueCol) ? MDB2_FETCHMODE_ASSOC : MDB2_FETCHMODE_ORDERED; } while (is_array($row = $result->fetchRow($fetchMode)) ) { if (($fetchMode == DB_FETCHMODE_ASSOC) || ($fetchMode == MDB2_FETCHMODE_ASSOC)){ $this->addOption($row[$textCol], $row[$valueCol]); } else { $this->addOption($row[0], $row[1]); } } return true; } // end func loadDbResult Remember to use getDatabaseResult() for saving result of a query.
 [2012-04-08 17:16 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!