MySQL Timestamp - why all zeros?(MySQL 时间戳 - 为什么全为零?)
问题描述
我正在使用 PHPMyAdmin,并且有一个名为时间戳"的 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
我已经明确地将默认值设置为无,但是当我保存并返回查看时,它被设置为如上所示的全零.
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.
我错过了什么?
推荐答案
我错过了什么?
你不更新:)
使用 DEFAULT CURRENT_TIMESTAMP
和 ON UPDATE CURRENT_TIMESTAMP
这篇关于MySQL 时间戳 - 为什么全为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 时间戳 - 为什么全为零?


- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01