Timestamp Not Updating
Got me a table with a field that should contain the date & time the record was inserted/updated:
However, the value for last_updated is "0000-00-00 00:00:00" after this query is run:
CREATE TABLE `ae_users` (
`location` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`item_name` tinytext COLLATE utf8_unicode_ci NOT NULL,
`item_cost` decimal(10,0) NOT NULL,
`item_percent` decimal(10,0) NOT NULL,
PRIMARY KEY (`location`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Same result for insert or update. Server version is 5.1.52. Any suggestions why last_updated doesn't show the current timestamp?
$query = sprintf("INSERT INTO ae_users (location,last_update,item_name,item_cost,item_percent)
ON DUPLICATE KEY UPDATE item_name=VALUES(item_name),item_cost=VALUES(item_cost),item_percent=VALUES(item_percent)",
drop last update from the insert entirely, it will still update.
Ah, that's right. Seems having that there was causing (probably) an illegal value that was changed to "zero." Thanks for the second set of eyes! Congrats on 1500 posts, too!