[php] how can I use pdo to get the last inserted data?

user structure

< table > < thead > < tr > < th > id < / th > < th > user < / th > < th > pwd < / th > < th > create_time < / th > < th > update_time < / th > < / tr > < / thead > < / table >
$pdo = new PDO(...);// pdo 
$stmt = $pdo->prepare("insert `user` (`user`,`pwd`) values("aaa","bbb")");

$res = $stmt->execute(); // (bool)true
$stmt->rowCount(); // 1   
$pdo->lastInsertId(); // 1 ID
// 

if the insert is successful, you get

< table > < thead > < tr > < th > id < / th > < th > user < / th > < th > pwd < / th > < th > create_time < / th > < th > update_time < / th > < / tr > < / thead > < tbody > < tr > < td > 1 < / td > < td > aaa < / td > < td > bbb < / td > < td > 100000000 < / td > < td > 100000000 < / td > < / tr > < / tbody > < / table >

for example, the front end wants to get a newly created json object {"id": 1, "user": "aaa", "pwd": "bbb", "create_time": "100000000", "update_time": "100000000"}
how to return this data?

Mar.24,2021

you can query the records through lastInsertId,. Any return

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38170-2c0dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38170-2c0dc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?