Ignore MySQL foreign key constraints in PHP

前端 未结 4 1569
生来不讨喜
生来不讨喜 2021-02-19 10:17

Is there a way to override mysql foreign key constraints in a php script?

I have a query passed to mysql from php, but it fails a foreign key constraint, is there any wa

4条回答
  •  情书的邮戳
    2021-02-19 11:01

    You can execute that MySQL query to disable foreign keys check:

    SET FOREIGN_KEY_CHECKS=0;
    

    Don't forget to enable it when you're done:

    SET FOREIGN_KEY_CHECKS=1;
    

提交回复
热议问题