I'm executing the following in PHP5.3:
$sql = "
CREATE TRIGGER `_photo_fulltext_insert` AFTER INSERT ON `photo` FOR EACH ROW INSERT INTO `_photo_fulltext` SELECT * FROM `photo` WHERE `id`=NEW.`id`;
CREATE TRIGGER `_photo_fulltext_delete` AFTER DELETE ON `photo` FOR EACH ROW DELETE FROM `_photo_fulltext` WHERE `id`=OLD.`id`;
DELIMITER |
CREATE TRIGGER `_photo_fulltext_update` AFTER UPDATE ON `photo`
FOR EACH ROW BEGIN
DELETE FROM `_photo_fulltext` WHERE `id`=NEW.`id`;
INSERT INTO `_photo_fulltext` SELECT * FROM `photo` WHERE `id`=NEW.`id`;
END;
|
DELIMITER ;
";
$mysqli->multi_query($sql);
The "photo_fulltext_update" trigger isn't getting created. This statement does run (and creates all the triggers) in phpMyAdmin. I've read online somewhere that the MySQL server doesn't support the DELIMITER statement at all, so I'm looking for a way to re-write this multi-step CREATE TRIGGER statement so that mysqli::multi_query can send it to MySQL.
Thanks!
This may help you:
PHP: multiple SQL queries in one mysql_query statement
this might help as well: the following creates a trigger on selectes tables. change the code and it might do what you want. https://github.com/junicom/mysqltriggerscript
While the
mysqli
doesn't to anything withDELIMITER
inmulti-query
statements, it actually doesn't do anything with any delimiters at all in normal queries, so just shove your triggers in one by one: