Re: Transactions in MD2

From: Date: Sat, 19 May 2007 13:09:51 +0000
Subject: Re: Transactions in MD2
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-27327@lists.php.net to get a copy of this message
Thanks a lot, seems like this works. If it turns out not to work, I'll come back ;) Regards, Florian -----Original Message----- Mark Wiesemann hat folgendes geschrieben:
Hi Florian, Florian Schmitz wrote: I think that a better piece of code would be something like: $mdb2->beginTransaction(); $result = $mdb2->query($sql); if (PEAR::isError($result)) { $mdb2->rollback(); // Handle error in application. return; } [snip] $mdb2->commit();
That was exactly what I had in mind and wanted to avoid, because it horribly increases the number of lines of code, without adding any new functionality. It would be fine if I could tell MDB2 to call the error handler of my application, then this one could do the rollback. So far I've only found the debug_handler setting, but this seems to be useful for query rewriting rather.
The error callback mechanism from PEAR should help you: http://pear.php.net/manual/en/core.pear.pear.seterrorhandling.php Regards, Mark


« previous php.pear.general (#27327) next »