Using transactions in Outlet

4 views
Skip to first unread message

kim

unread,
Nov 19, 2009, 8:26:37 AM11/19/09
to Outlet ORM
Hi,

quite simple: is it possible to use transaction in outlet

that is:

beginTransaction

do somethin

if ok then
commit

else rollback;


i can tell from the code that outlet uses transaction internally. i
would like to be able to rollback some transactions if i encounter an
error.

kim

alvaro

unread,
Nov 19, 2009, 3:48:01 PM11/19/09
to Outlet ORM
Hi, kim
Yes, you can use transactions like that, the methods are on the
OutletConnection object. Here is how to do it:

$con = $outlet->getConnection();
$con->beginTransaction();
try {

// run your code

$con->commit();
} catch (Exception $e) {
$con->rollback();
}

Those calls are delegated straight to the PDO object if it supports
them, or for some drivers they are emulated running actual query.
Either way, that should work.

Alvaro
Reply all
Reply to author
Forward
0 new messages