Disabling triggers for PHP script with MySQLi

I am working with a medium-sized DBMS in MySQL and I am updating the model. This Db has various tables, strictly correlated, and uses foreign keys and triggers to update related data. Now I am working on a PHP script to transfer data from the old to the new database model, and I have a slight problem with triggers. For the whole life of the database, the triggers will remain and work well, but before that, I need to load the data with the triggers turned off. The cleanest solution for me is to turn off all triggers before loading data and turn them on at the end of the procedure ... How can I do this?

+4
source share
1 answer

It is currently not possible to disable triggers (see Triggers: enable or disable ).

What you can do is change the triggers to check the session variable (e.g. @triggers_disabled), and if it is set, do nothing.

0
source

Source: https://habr.com/ru/post/1542899/