Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在表中插入一行,其中行的第二个元素(chatID)复制自动递增主键(messageID)的值。
safe_query("INSERT INTO ".PREFIX."messenger ('messageID', 'chatID') VALUES('','')");
任何想法都会非常有帮助。谢谢。
在 php 中,当您插入记录时,获取lastInsertId();并更新 chatID
lastInsertId();
$inserted_id = $pdo->lastInsertId(); $sth2 = $pdo->prepare("UPDATE ".PREFIX."messenger SET `chatID`= $inserted_id WHERE `messageID`=$inserted_id"); $sth2->execute();