我正在尝试创建一个触发器,将输入日期更改为 unix 时间戳。当我向表中插入一个值时,插入的值为 NULL
CREATE TRIGGER `updateDate` BEFORE INSERT ON `tl_calendar_events`
FOR EACH
ROW SET NEW.startDate = UNIX_TIMESTAMP(STR_TO_DATE(NEW.startDate, '%d.%m.%Y'))
'startDate' 的输入值类似于 01.11.2013
表定义:
CREATE TABLE IF NOT EXISTS `tl_calendar_events` (
...
`startDate` int(10) unsigned DEFAULT NULL,
...
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=66 ;