MySQL时间戳-为什么全为零? [英] MySQL Timestamp - why all zeros?
问题描述
我正在使用PHPMyAdmin,并且有一个名为"timestamp"的MySQL表列.类型(惊奇!)是TIMESTAMP
,在属性"中,我将其设置为ON UPDATE CURRENT_TIMESTAMP
.
I'm using PHPMyAdmin and I've got a MySQL table column called "timestamp." The type (surprise!) is TIMESTAMP
, and in 'attributes' I've set it to ON UPDATE CURRENT_TIMESTAMP
.
但是,每条新记录都有一个如下所示的时间戳:
However, each new record gets a timestamp that looks like this:
0000-00-00 00:00:00
我已经将默认值显式设置为none,但是当我保存并重新查看时,如上所述,它被设置为全零.
I have explicitly set the default value to none, but when I save and come back to look, it is set to all zeros as above.
与此查询相关的PHP记录页面匹配:
The relevant PHP records page hits with this query:
$query = "INSERT INTO `pagehit` (user_id, pageurl)
VALUES ('" . $userid . "', '" . $pageurl . "')";
整个事情都在XAMPP下运行.
The whole thing is running under XAMPP.
我想念什么?
推荐答案
我想念什么?
What am I missing?
您不更新:)
与ON UPDATE CURRENT_TIMESTAMP
一起使用DEFAULT CURRENT_TIMESTAMP
这篇关于MySQL时间戳-为什么全为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!