dqcd84732 2013-07-19 11:48
浏览 44

mysql_insert_id返回奇数?

I know it's depreciated, and not generally good practice. But this command: mysql_insert_id for some reason is returning this weird number. And it never has done before.

I cannot find reference to this number anywhere. For instance, I just inserted a record into id:2, and it gives me the number 1587.

Where is getting that from?

I've had to resort to reverse-querying the database with the exact values that i've just pulled out of it to get the ID. But this makes no sense.

Edit Sorry if I didnt explain this; but it is just a standard insert statement:

INSERT INTO `job` (`subject`,`deadline`,`status`) VALUES ('$title','3454354','CREATED');

And the autoincrement is on the PK which is called 'id'.

The field id results in being set to 2, but mysql_insert_id returns an odd number. I ran a table status and it shows the auto_increment to be as expected. I am not inserting anything else in this time. Literraly straight after I insert it I am querying for the last inserted ID.

  • 写回答

2条回答 默认 最新

  • doumengmian1180 2013-07-19 12:03
    关注

    chceck AUTOINCREMENT col before inserting, and after

    SHOW TABLE STATUS FROM `db_name` WHERE NAME='col_name';
    

    EDIT: You can see in "create table" if You have huge start number.

    Maybe You have Trigger on this table ?

    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染