MySQL: LAST_INSERT_ID() returns 0

前端 未结 6 1571
天涯浪人
天涯浪人 2020-11-30 07:28

I\'ve got this test table:

CREATE TABLE IF NOT EXISTS `test` (
    `id` INT(10) AUTO_INCREMENT,
    PRIMARY KEY (`id         


        
6条回答
  •  没有蜡笔的小新
    2020-11-30 08:19

    I had the same issue. mysql_insert_id() or LAST_INSERT_ID() returned 0 when requested inside a PHP function with an INSERT query.

    I sorted the issue by requesting the value of mysql_insert_id() from a separate PHP function called right after the function that INSERT query.

提交回复
热议问题