I need to insert a row to table where second element of the row (chatID) copies value of auto incremented primary key (messageID).
safe_query("INSERT INTO ".PREFIX."messenger ('messageID', 'chatID') VALUES('','')");
Any ideas would be very helpful. Thanks.
In php when you inserted the record get the lastInsertId();
and update the chatID
$inserted_id = $pdo->lastInsertId();
$sth2 = $pdo->prepare("UPDATE ".PREFIX."messenger
SET `chatID`= $inserted_id WHERE `messageID`=$inserted_id");
$sth2->execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.