【问题标题】:PHP&MySQL: Is it possible after running mysql_query with an insert to get the ID of the new row?PHP&MySQL:是否可以在运行 mysql_query 并插入以获取新行的 ID 后?
【发布时间】:2009-03-03 19:49:00
【问题描述】:

有没有一种直接的方法来运行 mysql_query 并获取新行的 ID,例如在返回中?还是我必须使用 select 进行另一个查询来检查它?

【问题讨论】:

    标签: php mysql insert-query


    【解决方案1】:

    mysql_insert_id()

    选择 last_insert_id()

    【讨论】:

      【解决方案2】:

      运行 mysql_query 后只需调用mysql_insert_id 即可获得 ID。

      【讨论】:

        【解决方案3】:

        【讨论】:

          猜你喜欢
          • 2010-10-28
          • 1970-01-01
          • 2011-08-16
          • 1970-01-01
          • 2012-01-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多