f3 框架:游标方法 `load` 的意外行为

f3 framework: unexpected behaviour of Cursor Method `load`

我在 循环 中使用 load 方法来执行一组查询,每个查询都像这样:

$events->load( "`user_id` = {$users->id} AND `action` = \"view\"");

其中 $events 映射器 并且每个加载的记录代表日志 table 中的一个 "event"(当然)。

load 调用之后,我将遍历找到的记录:

while( ! $events->dry() )
{
    // do something with $event

    $events->next();
}

当(内部)while 循环终止时,将执行另一个主循环迭代,因此再次调用 load

此代码没有产生预期的行为,因为某些 事件 显然未加载。

我可以通过在 $events->load 语句之前放置 $events->reset()$events->first() 来修复它。

但是从 documentation

load


Map to first record that matches criteria

[...] It uses find() to load records and makes the first record (mapper object) that matches criteria the active record. Additional records that match the same criteria can be made the active record by moving the cursor pointer

现在 问题是:这是 f3bug 还是我遗漏了什么?

而且 reset()first()(表面上)都解决了问题,哪一个更合适?

这是旧版本 F3 (3.4) 的问题。

更新到 3.6 解决了问题。