PHP/MySQL - “BEGIN…COMMIT” Not Working

后端 未结 4 1786
萌比男神i
萌比男神i 2021-01-18 04:31

I was searching for a way to insert data into two database tables in a single query in such a way that if one failed, neither saved (I don\'t want orphaned data). I came ac

4条回答
  •  再見小時候
    2021-01-18 05:05

    Make sure you're using an InnoDB table and not a MyISAM table, as MyISAM is not transactional.

    To use an InnoDB table, when you create it, after the closing paren, add ENGINE=InnoDB. By default, MyISAM is used.

提交回复
热议问题