Reserving mySQL auto-incremented IDs?

前端 未结 3 1963
既然无缘
既然无缘 2021-02-15 14:15

We want to obtain an auto-increment ID from mySQL without actually storing it until the other non-mysql related processes are successfully completed, so that the entry is not st

3条回答
  •  面向向阳花
    2021-02-15 15:00

    Have you considred using mysql tranactions?

    The essense of it, you start a transaction, if all sql statements are correct and can be complteted, then you commit your transaction. If not, then you rollback as if nothing happened.

    More details can be read in this link: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-transactions.html

提交回复
热议问题