I am writing a custom WP plugin.
While installing the plugin, custom tables are created in WP database.
What I want is some WP method to create a trigger for my table.
It seems that wpdb->query()
is not working for creating triggers.
My code is:
global $wpdb;
$sql = "
DROP TRIGGER IF EXISTS `delete_distributer_related_data`;
DElIMITER //
CREATE TRIGGER `delete_distributer_related_data` AFTER DELETE ON `naqdina_distributers`
FOR EACH ROW delete from naqdina_addresses where address_reference_type ='distributer' and
id = OLD.id //
DElIMITER";
$wpdb->query($sql);
Any help is much appreciated.