我在mysql终端中用一组sql语句创建了一个事件,它运行正常.但是我想从PHP脚本创建这个事件.我的查询如下.
DELIMITER |
CREATE EVENT e_cart
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 3 MINUTE
DO
BEGIN
SET @var_orderid = '';
SET @var_orderid = (SELECT orderid FROM order WHERE id=308);
IF @var_orderid = NULL THEN
UPDATE order SET status=1 WHERE id=308;
END IF;
END |
DELIMITER ;
这导致: –
Error : You have an error in your sql Syntax; check the manual that corresponds to your MysqL server version for the right Syntax to use near ‘DELIMITER |
CREATE EVENT e_cart
ON SCHEDULE AT CUR’ at line 1
如何从PHP脚本执行此事件?
解决方法:
DELIMITER不是MysqL服务器命令,而是MysqL CLI / Query browser / Workbench等.它只说何时向MysqL服务器发送命令.
省略DELIMITER并将整个CREATE EVENT语句作为一个命令发送,它应该可以工作.