Mysql transactions issue
- by Stann
In straight mysql script I'd do transactions like this:
START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;
i'm a little confused about how transactions work in PDO. It looks like there are beginTransaction() and commit() methods - so I'm not sure are these just convenience wrappers around staright SQL? or are they doing some more job behind the doors?
In other words - are these examples below essentially the same?
example 1:
$dbh->exec( 'START TRANSACTION' );
//...do some db work here...
$dbh->exec( "COMMIT" );
example 2:
$dbh->beginTransaction();
//...do some db work here...
$dbh->commit();