I try to perform this query with 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;
");
In phpMyAdmin QSL all go fine, and I create this event with if conditions before UpdatE But from PHP I receive this error:
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
I think this is because Zend DB query execute only one query and I have more than one. How I can solve.
I think the best way is to use a PHP script with a cron to do the job so you can drop the EVENT requirement. Keeps is portable as shell_exec() will not be possible on all environments and does not qualify as a 'good' solution if you ask me.