I need to store the following query text ($triggerTachoAdresa
) in a database. But it is perceived as part of the query. How to achieve that it is stored in the text column in the same way unchanged? I am using PDO.
$triggerTachoAdresa = "CREATE TRIGGER `TachoAdresa_{$cisloJednotky}` BEFORE INSERT ON `gps_{$cisloJednotky}`
FOR EACH ROW BEGIN
DECLARE iLastTacho BIGINT(12) DEFAULT 0;
DECLARE iLastKm BIGINT(12) DEFAULT 0;
SELECT VZDALENOST, IF (TACHOMETR IS NULL, 0, TACHOMETR) as TACHOMETR into iLastKM, iLastTacho FROM gps_{$cisloJednotky} ORDER BY DATUM_CAS DESC LIMIT 1;
IF iLastTacho = 0 THEN
SET NEW.TACHOMETR = NEW.VZDALENOST;
ELSE
SET NEW.TACHOMETR = iLastTacho + (NEW.VZDALENOST - iLastKM);
END IF;
SET NEW.ADRESA = DejAdresu(NEW.LAT, NEW.LON, {$cisloJednotky});
END";