How to get last inserted inserted row id from PDO

前端 未结 2 912
盖世英雄少女心
盖世英雄少女心 2020-12-19 10:43

I am following mvc structure in PHP and I want to retrieve last inserted row ID.

I have created following sql code:

$sql = \"INSERT          


        
2条回答
  •  既然无缘
    2020-12-19 11:05

    You're almost there.

    If you look at the manual page for lastInsertId, it's called on the database handle - you're currently calling it on the statement.

    You just need to call:

    $this->db->lastInsertId();
    

提交回复
热议问题