David Bélanger
David Bélanger

Reputation: 7438

MySQL Transaction - How to group?

I just learned about transaction few days ago and I find it very useful in some situation like when I update few tables and the script may fail in the middle of the operation, quite nice.

However, how can I group them ? It can happen that a query is ran between two queries in the transaction but I don't want it to rollback. Is there a way that I can group query without a new connection ?

I have searched but I got poor to nothing result.

I am using InnoDB, PHP/PDO + MySQL.

Thanks.

Upvotes: 0

Views: 153

Answers (1)

jcho360
jcho360

Reputation: 3759

you can try with the begin-end, where you can execute multiple queries inside those tags. You are working with TRANSACTIONS, so you only have two options COMMIT and ROLLBACK, if your query is not successful it will ROLLBACK (no more option), Please take a look to this post

START TRANSACTION inside BEGIN ... END context or outside and LOOP syntax

Upvotes: 1

Related Questions