Using Prepared Statement, how I return the id of the inserted row?

后端 未结 3 539
遥遥无期
遥遥无期 2020-12-03 04:23

I want retrieve the id of a inserted row in the database, but I don\'t know how to do this.

I tried to return using the SQL clause RETURNING id, but not

3条回答
  •  既然无缘
    2020-12-03 04:45

    You need to use:

    $stmt = $db->prepare("SQL Query");
    $stmt->execute();
    $id = $db->lastInsertId();
    

提交回复
热议问题