<bdo id='oL1BH'></bdo><ul id='oL1BH'></ul>
  • <i id='oL1BH'><tr id='oL1BH'><dt id='oL1BH'><q id='oL1BH'><span id='oL1BH'><b id='oL1BH'><form id='oL1BH'><ins id='oL1BH'></ins><ul id='oL1BH'></ul><sub id='oL1BH'></sub></form><legend id='oL1BH'></legend><bdo id='oL1BH'><pre id='oL1BH'><center id='oL1BH'></center></pre></bdo></b><th id='oL1BH'></th></span></q></dt></tr></i><div id='oL1BH'><tfoot id='oL1BH'></tfoot><dl id='oL1BH'><fieldset id='oL1BH'></fieldset></dl></div>

    1. <small id='oL1BH'></small><noframes id='oL1BH'>

      1. <tfoot id='oL1BH'></tfoot>
        <legend id='oL1BH'><style id='oL1BH'><dir id='oL1BH'><q id='oL1BH'></q></dir></style></legend>

        PDO lastInsertId 问题,php

        时间:2023-10-05
        <i id='nWxsf'><tr id='nWxsf'><dt id='nWxsf'><q id='nWxsf'><span id='nWxsf'><b id='nWxsf'><form id='nWxsf'><ins id='nWxsf'></ins><ul id='nWxsf'></ul><sub id='nWxsf'></sub></form><legend id='nWxsf'></legend><bdo id='nWxsf'><pre id='nWxsf'><center id='nWxsf'></center></pre></bdo></b><th id='nWxsf'></th></span></q></dt></tr></i><div id='nWxsf'><tfoot id='nWxsf'></tfoot><dl id='nWxsf'><fieldset id='nWxsf'></fieldset></dl></div>
        • <bdo id='nWxsf'></bdo><ul id='nWxsf'></ul>

                1. <small id='nWxsf'></small><noframes id='nWxsf'>

                2. <legend id='nWxsf'><style id='nWxsf'><dir id='nWxsf'><q id='nWxsf'></q></dir></style></legend>

                    <tbody id='nWxsf'></tbody>
                  <tfoot id='nWxsf'></tfoot>
                  本文介绍了PDO lastInsertId 问题,php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经尝试了很多方法来使用下面的代码(来自较大班级的片段)获取最后插入的 ID,现在我已经放弃了.

                  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.

                  有谁知道如何让 PDO lastInsertId 工作?

                  Does anyone know howto get PDO lastInsertId to work?

                  提前致谢.

                      $sql = "INSERT INTO auth (surname, forename, email, mobile, mobilepin, actlink, regdate) VALUES (:surname, :forename, :email, :mobile, :mobpin, :actlink, NOW())";
                  $stmt = $this->dbh->prepare($sql);
                  if(!$stmt) {
                   return "st";
                  }
                  
                  $stmt->bindParam(':surname', $this->surname);
                  $stmt->bindParam(':forename', $this->forename);
                  $stmt->bindParam(':email', $this->email);
                  $stmt->bindParam(':mobile', $this->mobile);
                  $stmt->bindParam(':mobpin', $this->mobilePin);
                  $stmt->bindParam(':actlink', $this->actlink);
                  
                  $result = $stmt->execute();
                  //return var_dump($result);
                  $arr = array();
                  $arr = $stmt->errorInfo();
                  $_SESSION['record'] = 'OK' . $dbh->lastInsertId();
                  $arr .= $_SESSION['record'];
                  return $arr;
                  

                  推荐答案

                  在您的代码片段中,我看到了一些可能对问题产生影响的轻微不一致.例如,在准备您使用的 SQL 语句的代码中,

                  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); 
                  

                  注意 $this 关键字.然后要检索 ID,您调用,

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

                  $dbh->lastInsertId();
                  

                  你有没有试过使用,

                  $this->dbh->lastInsertId();

                  这篇关于PDO lastInsertId 问题,php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PDO 在 PHP5.4 中以字符串形式返回整数列 下一篇:PHP/PDO:创建表时准备好的语句不起作用?

                  相关文章

                  最新文章

                    <tfoot id='HVQQQ'></tfoot>
                    <i id='HVQQQ'><tr id='HVQQQ'><dt id='HVQQQ'><q id='HVQQQ'><span id='HVQQQ'><b id='HVQQQ'><form id='HVQQQ'><ins id='HVQQQ'></ins><ul id='HVQQQ'></ul><sub id='HVQQQ'></sub></form><legend id='HVQQQ'></legend><bdo id='HVQQQ'><pre id='HVQQQ'><center id='HVQQQ'></center></pre></bdo></b><th id='HVQQQ'></th></span></q></dt></tr></i><div id='HVQQQ'><tfoot id='HVQQQ'></tfoot><dl id='HVQQQ'><fieldset id='HVQQQ'></fieldset></dl></div>

                    <small id='HVQQQ'></small><noframes id='HVQQQ'>

                  1. <legend id='HVQQQ'><style id='HVQQQ'><dir id='HVQQQ'><q id='HVQQQ'></q></dir></style></legend>
                    • <bdo id='HVQQQ'></bdo><ul id='HVQQQ'></ul>