Handling foreign key exceptions in PHP

前端 未结 2 1137
臣服心动
臣服心动 2020-12-19 09:57

What is the best way in PHP to handle foreign key exceptions on a mysql database? Is there a mysql class that can be used to simplify any code?

Ideally, what I want

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 10:41

    I think the best bet would be for you to do a transaction. That way, the insert will always be valid, or not done at all. That can return an error message that you can work with as well. This will prevent you from having to manually check every table - the db does it for you.

提交回复
热议问题