PDO lastInsertId issues, php

前端 未结 1 1605
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 17:41

I have tried lots of ways to get the last inserted ID with the code below (snipplet from larger class) and now I have given up.

Does anyone know howto get PDO lastIn

相关标签:
1条回答
  • 2020-12-11 17:52

    In your code snippet, I saw some minor inconsistencies that may have an effect on the problem. For an example, in the code to prepare your SQL statement you use,

    $stmt = $this->dbh->prepare($sql); 
    

    Notice the $this keyword. Then to retrieve the ID, you call,

    $dbh->lastInsertId();
    

    Have you tried using,

    $this->dbh->lastInsertId();

    0 讨论(0)
提交回复
热议问题