Mysql transactions issue -
in straight mysql script i'd transactions this:
start transaction; select @a:=sum(salary) table1 type=1; update table2 set summary=@a type=1; commit; i'm little confused how transactions work in pdo. looks there begintransaction() , commit() methods - i'm not sure these convenience wrappers around staright sql? or doing more job behind doors?
in other words - these examples below same?
example 1:
$dbh->exec( 'start transaction' ); //...do db work here... $dbh->exec( "commit" ); example 2:
$dbh->begintransaction(); //...do db work here... $dbh->commit();
functionality wise both same, begintransaction() , commit() pdo functions ensures compatibility database , there might database may give error @ start transaction pdo methods work.
Comments
Post a Comment