简体   繁体   English

当前时间更新MySQL查询

[英]Current Time Update MySQL Query

I am trying to update my field with current time during update query but its not working for some reason. 我正在尝试在更新查询期间以当前时间更新我的字段,但是由于某种原因它不起作用。 My field Time is datetime type and Default set as Current Time stamp. 我的字段时间是日期时间类型,默认设置为当前时间戳。 I need update that time when I update one other field. 我需要更新其他字段的时间。 My Query is like this and working fine without update time 我的查询就是这样,并且无需更新即可正常工作

mysql_query("update tbl_quotes set quote_status='0' where id=".$_REQUEST['up_dea']."");

I have tried to update my time field with below query but its not updating.... 我试图用以下查询更新我的时间字段,但未更新...。

mysql_query("update tbl_quotes set quote_status='0',Time=getDate() where id=".$_REQUEST['up_dea']."");

Let me know if someone know what is wrong with this... 让我知道是否有人知道这是怎么回事...

Thanks 谢谢

Alter your table with: 使用以下方法更改表格:

ALTER TABLE table_name
MODIFY datetime_column DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;

This way, every time when a record is updated, its timestamp will be updated. 这样,每次更新记录时,其时间戳都会被更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM