【问题标题】:With Kohana 3, how can I get the last insert ID from the Database class?使用 Kohana 3,如何从 Database 类中获取最后一个插入 ID?
【发布时间】:2010-02-15 06:06:02
【问题描述】:

我已经通过了 modules/database/classes/ 中的一些代码,但仍然没有找到如何返回最后一个插入 ID。

我如何得到这个?

【问题讨论】:

    标签: php mysql kohana kohana-3 lastinsertid


    【解决方案1】:

    query() 方法返回一个数组,其中包含最后插入的 id 和受影响的行数

    实际代码位于 mysql.php (kohana v3.0.3) 的第 201-208 行

    【讨论】:

    • 有什么用?这不起作用(方法不存在)DB::query(Database::INSERT, $query)->execute()->query()
    • 看看 DB::query(Database::INSERT, $query)->execute() 返回什么
    • 顺便说一句,我刚刚从我的第一条评论中查看了我的代码 - 哎呀!我在想什么?
    猜你喜欢
    • 1970-01-01
    • 2012-11-09
    • 2011-03-06
    • 1970-01-01
    • 2014-02-18
    • 1970-01-01
    • 2011-05-07
    • 2023-03-16
    • 2011-04-30
    相关资源
    最近更新 更多