Re: Transactions in MD2
| From: | Mark Wiesemann | Date: | Sat, 19 May 2007 12:00:03 +0000 |
| Subject: | Re: Transactions in MD2 | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27326@lists.php.net to get a copy of this message | ||
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
--
http://www.markwiesemann.eu