PDO get the last ID inserted

前端 未结 3 2113
一整个雨季
一整个雨季 2020-11-22 13:59

I have a query, and I want to get the last ID inserted. The field ID is the primary key and auto incrementing.

I know that I have to use this statement:



        
3条回答
  •  悲&欢浪女
    2020-11-22 14:48

    You can get the id of the last transaction by running lastInsertId() method on the connection object($conn).

    Like this $lid = $conn->lastInsertId();

    Please check out the docs https://www.php.net/manual/en/language.oop5.basic.php

提交回复
热议问题