【发布时间】:2012-01-06 08:43:39
【问题描述】:
这就是我使用 MySQLi 获得一条记录的方式:
$result = $db->query("...");
$image = $result->fetch_object();
现在我需要获取 cmets 并将其传递给视图。我现在正在这样做,但似乎不对:
$result = $db->query("...");
while ($row = $result->fetch_object())
$comments[] = $row;
我想知道是否有办法消除循环?有 $image = $result->fetch_object(((s))) 之类的东西,所以我的代码如下所示:
$result = $db->query("...");
$comments = $result->fetch_objects();
【问题讨论】: