I would like to have a Trigger on a failed Update which will insert into the same table.
If possible, I would prefer avoiding any additional php and SELECT due to performance.
So I thought of something like this for the TRIGGER:
CREATE TRIGGER `onChunksUpdate` AFTER UPDATE ON `chunks`
FOR EACH ROW
IF ROW_COUNT() = 0
THEN INSERT INTO chunks( scopeX, scopeY, targets )
VALUES (NEW.scopeX, NEW.scopeY, NEW.targets);
END IF ;
And the executed Update statement(php):
UPDATE chunks SET targets = CONCAT(targets, ',{$id}') WHERE scopeX={$chunkX} AND scopeY={$chunkY}
Furthermore I am not sure, wether a failed update call would still execute a TRIGGER of the time AFTER.
Thanks for any help, I googled very much to find any help but I found nothing.