gpt4 book ai didi

php - 更新mysql时间戳

转载 作者:可可西里 更新时间:2023-11-01 07:48:20 28 4
gpt4 key购买 nike

我有一个包含字段的表:

'last_modified - timestamp NOT NULL'

  • 我将默认值设置为当前时间戳。但是,这仅在从 phpMyAdmin 而不是从我的脚本更新或插入时有效。

我试过了

$sql = sprintf("UPDATE %s SET timestamp=now(), %s WHERE id='%s'", $table, $implodeArray, $_POST['id']);

它似乎仍然不起作用。当我从脚本中按表更新或插入时,如何更新时间戳?

还有一个脚本输出示例:

UPDATE about SET timestamp=now(), page_header = 'Page header goes here', sub_header = 'Sub header goes here', content_short = 'This is where a short description of the about page goes', content = 'This is where the full content description goes' WHERE id='1'

最佳答案

可能是我看错了,但是你的列名是last_modified(键入timestamp),所以查询应该是:

UPDATE about SET last_modified=now(), 
page_header = 'Page header goes here',
sub_header = 'Sub header goes here',
content_short = 'This is where a short description of the about page goes',
content = 'This is where the full content description goes'
WHERE id='1'

关于php - 更新mysql时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11311408/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com