php - Where to rollback a transaction in PDO? -
My problem is, I have a database design with this link
edit * OK Can use transactions? But where should I put a rollback, if it fails?
$ dbConnect-> gt; Startup (); $ Registrand = $ dbConnect-> ("Name,` address, `email`,` phone`, `link`, 'verified') value ((name: address,: email,: phone, link: verified)"); $ RegisterEnsert-> Execute ($ RegisterData); $ RegisterData2 ['CID'] = $ dbConnect-> gt; Last InsertID (); $ RegisterInterress = $ dbConnect-> INSERT VALUES ((UID, CID, Role)); $ RegisterInsert-> execute ($ RegisterData2); $ DbConnect- &
Where should I put rollback?
thanks
A transaction must end with either a rollback ()
or commit ()
(only one of them) < / P>
It is usually executed only one with a if ... and
statement Or go to.
< P>
A transaction is usually a complex argument associated with the question, then it is used.
If you are using MySQL, make sure that you do not use the MyISAM engine for tables because it does not support transactions.
Comments
Post a Comment