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

Bug #3096 processForm() should quit and return errors when they occur
Submitted: 2005-01-04 17:32 UTC
From: ate2 at cornell dot edu Assigned: justinpatrin
Status: Closed Package: DB_DataObject_FormBuilder
PHP Version: Irrelevant OS: Irrelevant (but Debian sarge)
Roadmaps: (Not assigned)    
Subscription  


 [2005-01-04 17:32 UTC] ate2 at cornell dot edu
Description: ------------ The processForm() method does a lot of database operations and from what I can tell it does not return any errors. Often, I want to handle certain errors that only occur after attempting to insert/update a record (i.e. report to a user that the unique "title" they selected for the record is already taken, handle complex multi-query transactions where an error should trigger a rollback() call). It seems to me that any call to insert(), update(), delete() or any other method that returns errors should be followed by a check. Thanks. Reproduce code: --------------- $do =& new DB_DataObject(); $db =& $do->getDatabaseConnection(); $fb =& DB_DataObject_FormBuilder::create($do); $form =& $fb->getForm(); if ($form->validate()) { $db->autoCommit(false); $e = $fb->processForm(); if (PEAR::isError($e)) { echo "Ack! Error occurred during processing."; $db->rollback(); } echo "Transaction succeeded!"; $db->commit(); $form->freeze(); } echo $form->toHtml(); Expected result: ---------------- "Ack! Error occurred during processing." Actual result: -------------- "Transaction succeeded!"

Comments

 [2005-01-04 18:59 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!
 [2005-01-04 21:50 UTC] ate2 at cornell dot edu
Something I didn't understand before (maybe you also weren't aware): DB_DataObject methods don't normally return errors. Instead they stop short and store the error in $do- >_lastError . There's also supposed to be a "static" variable that stores the most recent DBDO error, but it seems like that is not in the present implementation of DBDO (see bug #3098). But presently there's no proper public means of accessing the error. Strange.
 [2005-04-21 18:42 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!