考虑一下:
+---------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+-------------------+-----------------------------+
| email_address | varchar(100) | NO | PRI | NULL | |
| create_date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| optin_date | timestamp | YES | | NULL | |
| optout_date | timestamp | YES | | NULL | |
+---------------+--------------+------+-----+-------------------+-----------------------------+
使用PHP,如何使optin_date
和optout_date
列存储当前时间戳?
答案 0 :(得分:3)
您只能有一个current_timestamp列。对于第二个,您必须在插入/更新时使用触发器。