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

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

      • <bdo id='x9QNm'></bdo><ul id='x9QNm'></ul>
      <tfoot id='x9QNm'></tfoot>
    1. MySQL:LAST_INSERT_ID() 返回 0

      时间:2023-06-26
    2. <tfoot id='w2bN6'></tfoot>

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

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

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

              1. 本文介绍了MySQL:LAST_INSERT_ID() 返回 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有这个测试表:

                CREATE TABLE IF NOT EXISTS `test` (
                    `id` INT(10) AUTO_INCREMENT,
                    PRIMARY KEY (`id`)
                ) ENGINE=InnoDB AUTO_INCREMENT=4;
                

                使用这三个中的任何一个插入

                inserting using either of these three

                INSERT INTO `test` (`id`) VALUES (NULL);
                INSERT INTO `test` (`id`) VALUES (0);
                INSERT INTO `test` () VALUES ();
                

                和发行

                SELECT LAST_INSERT_ID();
                

                但查询结果总是0.

                PHP 的 mysql_insert_idPDO::lastInsertId() 也没有结果.

                PHP's mysql_insert_id and PDO::lastInsertId() yield no result either.

                我一整天都在玩弄这件事,但无法让它发挥作用.想法?

                I've been toying with this whole day and can't get it to work. Ideas?

                推荐答案

                问题似乎出在 MySQL 的 phpmyadmin 配置文件 PersistentConnections 设置为 FALSE 这导致了一个新的CONNECTION_ID 每次发出查询时 - 因此使 SELECT LAST_INSERT_ID() 无效.

                The problem seemed to be in MySQL's phpmyadmin config file PersistentConnections set to FALSE which resulted in a new CONNECTION_ID every time a query was issued - therefore rendering SELECT LAST_INSERT_ID() ineffective.

                后续主题中的更多信息每个查询都会创建一个新的 CONNECTION_ID()

                同时感谢dnagirl的帮助

                这篇关于MySQL:LAST_INSERT_ID() 返回 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:我不断收到此 mysql 错误代码 #1089 下一篇:MySQL“输入"使用子查询查询非常慢,但使用显式值查询速度很快

                相关文章

                <tfoot id='YTdHK'></tfoot>

                • <bdo id='YTdHK'></bdo><ul id='YTdHK'></ul>
                <legend id='YTdHK'><style id='YTdHK'><dir id='YTdHK'><q id='YTdHK'></q></dir></style></legend>

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

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