使用php的Mysql事件错误 [英] Mysql event error using php

查看:19
本文介绍了使用php的Mysql事件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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 ;

谁能找出问题所在?

在用户完成某事后 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

确认它已开启:

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

查看手册页了解完成保留 和其他东西一样.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆