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.

dbConnect-> gt; Startbank (); // somecode // $ dbConnect-> execute ($ some INnsert); // some more code // $ Result = $ dbConnect-> Execute ($ some selection); // $ nextRow = $ result- & gt; receive cry (); // either committed or rollback! If ($ some result check == True) $ dbConnect-> Comment (); and $ dbConnect->; Rollback ();

< 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

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -