DataObject and transactions
| From: | Markus Wolff | Date: | Fri, 15 Aug 2003 12:10:43 +0000 |
| Subject: | DataObject and transactions | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-7221@lists.php.net to get a copy of this message | ||
Hi there,
maybe some of you have encountered similar problems and can give me some hints:
I need to make several insert/select/update statements using
different DataObject-derived classes that all have to be part
of one transaction that is automatically rolled back if any
of the queries fail for some reason.
I´ve found some old postings in this ML from last year, where
Andrew Djachenko has tried to do it like this:
$do1 = new DO_Type1; $do1->query('begin work'); ... loop ... $do1->insert(); ... end loop ... $do2 = new DO_Type2; $do2->insert(); $do1->query('rollback');The rollback didn´t work for Andrew back then. Maybe this has changed in the time being? Now, DataObject uses DB. To use DB with transactions, you have to turn off autoCommit and issue a manual commit() after your last query. Is there a way to get DataObject to do the same? Is there anyone here who successfully got DO to work with transactions and still lives to talk about it? ;-) Another question: How can I find out if the transaction went through okay, or if it was rolled back because of some failure? And can I still query the reason for that failure? Thanks, Markus