2017-07-17 71 views
0

我想在兩個部分保存一個事件在MySQL事件管理器中,如下圖所示。ZF2 MYSQL事件管理器自定義查詢

我可以通過PHPMyAdmin的成功添加了,但ZF2 TAblegateway沒有快樂..

任何解決方案 - 直接通過PHP將是現在接受..

$this->tableGateway->getAdapter()->driver->getConnection()>execute($eventSql); 

$ eventSql =

"DELIMITER | 

    CREATE EVENT slacheckevent9 
    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTE 
    DO 
    BEGIN 

    UPDATE sla AS T1, 
    (SELECT eventdata FROM eventdata WHERE eventname = 'CUSTOMER 
    CONTACTED' AND instructionid=3) AS T2 
    SET T1.actualtime=T2.eventdata WHERE T1.id = 9; 

    UPDATE sla 
    SET slasuccess= CASE 
    WHEN actualtime <= duetime THEN true 
    ELSE slasuccess 
    END 
    WHERE id = 9 
    ; 



    END | 

    DELIMITER ;"; 
+0

'與ZF2 TAblegateway沒有快樂......你將不得不比這更具體一點。你有沒有收到任何錯誤信息?日誌消息?任何跡象顯示喜悅在哪裏? – Crisp

+0

對不起,這是一個漫長的一天,錯誤消息是在ajax查詢的數據中輸出的,所以隨着我的生活意願,快樂消失了。 – Leopard

回答

0

簡單:

$eventSql = " 
    CREATE EVENT slacheckevent9 
    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTE 
    DO 
    BEGIN 

    UPDATE sla AS T1, 
    (SELECT eventdata FROM eventdata WHERE eventname = 'CUSTOMER 
    CONTACTED' AND instructionid=3) AS T2 
    SET T1.actualtime=T2.eventdata WHERE T1.id = 9; 

    UPDATE sla 
    SET slasuccess= CASE 
    WHEN actualtime <= duetime THEN true 
    ELSE slasuccess 
    END 
    WHERE id = 9 
    ; 



    END 
    "; 
$this->tableGateway->getAdapter()->query($eventSql, \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE); 
+0

看來你不需要DELIMITER語句。 – Leopard