Rolling back queries

thread: 3 messages  |  last: a year ago  |  started: monday, august 2, 2010, 4:56 pm pdt


#1  |  CaptainChaos United Kingdom
Monday, August 2, 2010, 4:56 PM PDT

Hi,

I've just been having a read through the Qcodo documentation.  What happens when a delete or save method is invoked and the db connection fails?  Will it rollback the query or throw an exception?

What would be the best way to maintain referential integrity?


Thank you in advance :)

#2  |  VexedPanda (Calgary, AB) Canada
Tuesday, August 3, 2010, 9:05 AM PDT

If the db connection fails, the query couldn't have been sent. There is no chance of a partial success of a single query.

#3  |  marcosdsanchez (Buenos Aires, Argentina) Argentina
Tuesday, August 3, 2010, 12:06 PM PDT

This is the way to use transactions in Qcodo:

 try {
          QApplication::$Database[1]->TransactionBegin();
          //YOUR CODE
 } catch (Exception $objExc) {
          QApplication::$Database[1]->TransactionRollback();
          throw $objExc;
 }
         QApplication::$Database[1]->TransactionCommit();

Cheers,

Marcos



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.