irgendwie bekomme ich es gerade nicht gebacken. Ich benötige einen Trigger, welcher mir bei einem Update eines Datensatzes das modified-Feld auf den CURRENT_TIMESTAMP setzt.... und zwar immer AUßER, wenn das Attribut position verändert wird... Irgendwie muss das doch mit IF NOT UPDATE funktionieren aber ich bekomme es nicht hin:
Meine Tabelle:
Code: Alles auswählen
REATE TABLE IF NOT EXISTS `:prefix:mod_courseEntry` (
`entryID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`courseID` int(11) unsigned NOT NULL,
`content` text NULL,
`text` text NULL,
`modified` DATETIME NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`userID` int(11) unsigned NULL,
`seoURL` varchar(255) NOT NULL DEFAULT '',
`position` smallint(11) unsigned NULL DEFAULT '1',
PRIMARY KEY (`entryID`),
CONSTRAINT `courses` FOREIGN KEY (`courseID`) REFERENCES `:prefix:mod_course`(`courseID`) ON DELETE CASCADE,
CONSTRAINT `user` FOREIGN KEY (`userID`) REFERENCES `:prefix:users`(`user_id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Code: Alles auswählen
CREATE TRIGGER `courseEntryUpdate` BEFORE UPDATE ON `:prefix:mod_courseEntry` FOR EACH ROW
IF NOT UPDATE(position) BEGIN
SET NEW.modified = CURRENT_TIMESTAMP
END;