开发者

PHP+MySQL Update TimeStamp and get NOW() back

开发者 https://www.devze.com 2023-02-01 14:33 出处:网络
Is it possible to merge these two mysql queries into one? I want to get NOW() returned to a php variable.

Is it possible to merge these two mysql queries into one? I want to get NOW() returned to a php variable.

mysql_query('INSERT INTO translate (IDRef, RefType, Lang, Text, LastChangeTS) VALUES ('.$id.', \''.$reftype.'\', \''.$lang.'\', \''.$text.'\', NOW()) ON DUPLICATE KEY UPDATE text = \''.$text.'\', LastChangeTS = NOW()');

mysql_query('SE开发者_开发问答LECT LastChangeTS FROM translate WHERE IDRef = '.$id.' AND RefType = \''.$reftype.'\' AND Lang = \''.$lang.'\'');


You can't merge a insert statement and a select statement. But, you can sure use a stored procedure which inserts the data and then returns the LastChange value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号