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

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

        PDO 最后插入 ID 总是正确的吗?

        时间:2023-09-20

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

                <tbody id='KRgwn'></tbody>
              1. <small id='KRgwn'></small><noframes id='KRgwn'>

                <legend id='KRgwn'><style id='KRgwn'><dir id='KRgwn'><q id='KRgwn'></q></dir></style></legend>
              2. <tfoot id='KRgwn'></tfoot>
                  <bdo id='KRgwn'></bdo><ul id='KRgwn'></ul>
                • 本文介绍了PDO 最后插入 ID 总是正确的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有以下代码:

                  <?
                  $query =$db->prepare("INSERT INTO a_table (id, a_field) VALUES ('', (:a_field)");
                  $query->bindParam(":a_field", $a_value);
                  $query->execute();
                  $last_id = $db->lastInsertId('a_table');
                  ?>
                  

                  我想问的是这个.想象一下,当两个人完全同时加载页面时,是否有可能在检索到最后一个 ID 之前插入其他人的查询从而混淆 ID 的危险?

                  What I want to ask is this. Imagine when two people load the page at exactly the same time, is it a possible danger that the other persons query is inserted before the last ID is retrieved, mixing up the IDs?

                  推荐答案

                  不,这种情况是不可能的.方法 $db->lastInsertId() 返回此数据库连接的最后插入的 id.在其他页面将是另一个连接和另一个最后插入的 id.

                  No, this situation is impossible. Method $db->lastInsertId() returns last inserted id for this DB conection. In other page will be another connection and another last inserted id.

                  这篇关于PDO 最后插入 ID 总是正确的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:mysql_data_seek pdo 等价物 下一篇:PDO lastInsertId() 总是返回 0

                  相关文章

                  最新文章

                    <bdo id='UPC6v'></bdo><ul id='UPC6v'></ul>

                    <legend id='UPC6v'><style id='UPC6v'><dir id='UPC6v'><q id='UPC6v'></q></dir></style></legend>

                    1. <tfoot id='UPC6v'></tfoot>

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

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