1
我嘗試與Zend DB執行此查詢:的Zend DB查詢
$this->db->query("
CREATE EVENT turn_tonormal
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE COMMENT 'Return the calendar state to NORMAL'
DO
SELECT type FROM calendar WHERE id = 64;
UPDATE calendar SET type = IF(type = 'OK', 'OK', 'NRML') WHERE id=64;
DROP event turn_tonormal;
");
在phpMyAdmin QSL都去罰款,並與如果條件UPDATE 前,但是從PHP時我收到此我創建這個事件錯誤:
Mysqli prepare 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 'UPDATE mind_calendar SET timeband_type = IF(timeband_type = 'PRENOTED', 'PRENOTE' at line 5
我想這是因爲Zend DB查詢只執行一個查詢,我有不止一個。我如何解決。
在此先感謝和索裏的英語不好:)
Zend DB不允許您一次執行多個查詢。 – RMK
可能的重複[我如何運行多個SQL查詢每次調用「查詢」使用Zend \ _Db \ _Adapter?](http://stackoverflow.com/questions/7395056/how-do-i-run-multiple-sql -queries-per-call-to-query-using-zend-db-adapter) – RMK
非常感謝你,multi_query可以工作,但它的工作方式與對query()進行多重調用的方式相同。我認爲shell_exec()更好,但在這種情況下,我更喜歡更改我的邏輯並留下使用MySQL事件的想法。 –