更新mysql时间戳

Ale*_*lex 3 php mysql timestamp

我有一个带有字段的表:

'last_modified - timestamp NOT NULL'

  • 我将默认值设置为当前时间戳.但是这只适用于从phpMyAdmin更新或插入而不是从我的脚本更新或插入.

我试过了

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

它似乎仍然没有工作.当我从脚本中更新或插入表时,如何更新时间戳?

还有一个脚本输出示例:

UPDATE关于SET timestamp = now(),page_header ='页眉在这里',sub_header ='Sub header goes here',content_short ='这是关于about page的简短说明',content ='这是完整内容描述'WHERE id ='1'

Iva*_*oni 9

可能是我误读了,但你的列名是last_modified(键入的时间戳),所以查询应该是:

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'
Run Code Online (Sandbox Code Playgroud)