MYSQL EVENT or Something else ? trying to track clicks for links
Don't use the event scheduler, use a trigger that runs when updating the links
table:
DELIMITER $$
CREATE TRIGGER link_completed
BEFORE UPDATE ON links
FOR EACH ROW
BEGIN
IF NEW.bought = 0
THEN SET NEW.status = 'completed';
END IF;
END; $$
DELIMITER ;
Connection between MySQL Event and Table
Make a trigger like this:
SET @ename:='rec';
SET @sql_text = concat('CREATE TRIGGER delete_invoice_event AFTER DELETE on TABLE FOR EACH ROW BEGIN DROP EVENT IF EXISTS ', @ename ,'old.id END');
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
You have to use PREPARE statement, because your event name is dynamic, based on the deleted record id that would be accessible by old.id
Related Topics
How to Find the Date of a Day of the Week from a Date Using PHP
Check If String Contains a Value in Array
Get the Latest File Addition in a Directory
PHP Foreach Loop Through Multidimensional Array
What Does ${ } Mean in PHP Syntax
Manipulate an Archive in Memory with PHP (Without Creating a Temporary File on Disk)
How to Count Days Between Two Dates in PHP
PHP Date Format /Date(1365004652303-0500)/
Codeigniter - Best Place to Declare Global Variable
Uncompress Gzip Compressed Http Response
Jquery Mobile: How to Correctly Submit Form Data
How to Call a PHP Script/Function on a HTML Button Click
Unexpected Character in Input: '\' (Ascii=92) State=1