3

I created an event with a set of sql statements in mysql terminal, It is working fine. But I want to create this event from php script. My query is below.

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 ;

This results in :-

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

How do I execute this event from php script?

4

1 回答 1

7

DELIMITER 不是 MySQL 服务器命令,而是 MySQL CLI/Query Browser/Workbench 等。它只说明何时向 MySQL 服务器发送命令。

省略 DELIMITER 并将整个 CREATE EVENT 语句作为一个命令发送,它应该可以工作。

于 2012-08-11T09:30:35.363 回答