0

I'm creating an application using PHP and involving MySQL. If an error is made half way through out a request, how would I "group together queries", check if it would be successful, then do an actual affect to the real table(s). If the actual update to the table(s) fails, then revert to how it was before the update, and give a user error.

I use MySQLi, if that matters.

ekad
  • 14,436
  • 26
  • 44
  • 46
qaisjp
  • 722
  • 8
  • 31
  • 5
    The term you are looking for is "transaction" – lc. Jul 19 '12 at 17:07
  • I normally use MyISAM, my research says it doesn't support transactions. If this is true, what is the next best alternative for me to use? – qaisjp Jul 19 '12 at 17:14

1 Answers1

2

You will want to user a transaction: http://dev.mysql.com/doc/refman/5.0/en/commit.html

And the following question explains it pretty well: PHP + MySQL transactions examples

Community
  • 1
  • 1
sean
  • 3,955
  • 21
  • 28