使用PHP的MYSQL Event Scheduler DELIMITER [英] MYSQL Event Scheduler DELIMITER using PHP
问题描述
我的PHP代码在尝试在MySQL中创建事件时遇到问题。我先创建一个像这样的字符串:
<?php
$ sql = DELIMITER $$ CREATE EVENT $ test_name`安排每个$ time1 $ sched2
STARTS'$ start_date $ start_time'开始;
$ sql。=插入到blah(foo,bar);;
$ sql。= END $$ DELIMITER;;
mysql_query($ sql,$ dbh);
?>
但是我一直收到以 DELIMITER $$ CREATE EVENT开头的语法错误
。在(foo,bar);
后面没有分号的情况下,该事件将以未执行的有效负载触发。
谢谢!
进行更多研究后,发现这是mysql界面无法与DELIMITER配合使用。切换到mysqli正常工作。
由于某种原因,全局调度程序也停止运行,而没有引起我的注意,所以一旦我用 show processlist检查并重新启动它,现在我的工作就被解雇了。因此,我认为它将在没有DELIMITER噪音的情况下运行。
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!
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.
这篇关于使用PHP的MYSQL Event Scheduler DELIMITER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!