我正在尝试添加一个名为“lastLogin”的数据库字段,每次有人登录时都会填充该字段。 尝试添加字段时出错:
#1294 - Invalid ON UPDATE clause for 'lastLogin' column
我不确定出了什么问题 - 我在 phpmyadmin 中有以下设置:
field: lastlogin
type: date
standard: none
attribute: on update CURRENT_TIMESTAMP
知道哪里出了问题吗?
谢谢
最佳答案
您的字段类型设置为日期应该是时间戳或日期时间。
The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. It has varying properties, depending on the MySQL version and the SQL mode the server is running in. These properties are described later in this section.
关于php:数据库字段的current_timestamp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5683670/