使用php的Mysql事件错误 [英] Mysql event error using php
问题描述
我正在尝试使用PHP脚本启动MySQL事件。它使用phpMyAdmin(虽然我得到相同的错误),但不使用脚本。我收到以下错误:
I'm trying to initiate a MySQL Event using a PHP script. It works using phpMyAdmin (although I get the same error) but not using the script. I get the following error:
您的SQL语法有错误;检查对应于您的MariaDB服务器版本的手册,以便在第1行DELIMITER附近使用正确的语法。
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELIMITER' at line 1
DELIMITER |
CREATE EVENT myevent21222
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 MINUTE
DO
BEGIN
UPDATE `team` SET `reg` = '0' WHERE `id` = '1';
END |
# MySQL lieferte ein leeres Resultat zurück (d.h. null Datensätze).
DELIMITER ;
任何人都可以解决问题?
Can anyone figure out the problem?
在用户完成某项操作5分钟后,是否有任何替换数据库的方法?
Is there any alternative for changing data in a database after 5 minutes after a user had done something?
推荐答案
创建事件:
drop event if exists `myevent21222`;
DELIMITER |
CREATE EVENT myevent21222
ON SCHEDULE EVERY 5 MINUTE STARTS '2016-01-01 00:00:00'
ON COMPLETION PRESERVE
DO
BEGIN
UPDATE `team` SET `reg` = '0' WHERE `id` = '1';
END |
# MySQL lieferte ein leeres Resultat zurück (d.h. null Datensätze).
DELIMITER ;
打开事件处理程序:
SET GLOBAL event_scheduler = ON; -- turn her on and confirm below
确认它在: / p>
Confirm it is on:
show variables where variable_name='event_scheduler';
查看活动信息
show events from so_gibberish2; -- note so_gibberish2 is my database name
- 显然使用你的数据库名称
-- obviously use your database name above
查看手册页,了解 ON COMPLETION PRESERVE 表示以及其他事情。
Look at the manual page for what ON COMPLETION PRESERVE means as well as other things.
禁用或启用它:
ALTER EVENT myevent21222 disable;
ALTER EVENT myevent21222 enable;
这篇关于使用php的Mysql事件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!