MYSQL Event Scheduler DELIMITER using PHP

牧云@^-^@ 提交于 2019-12-13 04:45:37

问题


I'm having an issue with my PHP code trying to create events within MySQL. I begin with creating a string like this:

<?php
$sql="DELIMITER $$ CREATE EVENT `$test_name` ON SCHEDULE EVERY $time1 $sched2 
STARTS '$start_date $start_time' DO BEGIN ";
$sql .="INSERT INTO blah (foo,bar); ";
$sql .="END$$ DELIMITER ;";

mysql_query($sql,$dbh);
?>

But I keep getting Syntax Errors starting with DELIMITER $$ CREATE EVENT. Without the semicolon behind (foo,bar); the event triggers with a unexecuted payload.

Any ideas on where I'm going wrong?

Thanks!


回答1:


After some more research, it turns out to be the mysql interface not playing well with DELIMITER. Switching to mysqli worked.

For some reason the global scheduler stopped running as well without me noticing so once I checked for it with "show processlist" and restarted it, now my jobs are firing. So I think it will run without the DELIMITER noise.



来源:https://stackoverflow.com/questions/10923300/mysql-event-scheduler-delimiter-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!