Zend Db语句 - 重置循环

时间:2013-05-08 13:05:36

标签: zend-framework

我正在使用Zend Framework 1.12.2并构建一个查询:

$sitesSql = 'SELECT * FROM app_sites';
$stmtSites = $db->query($sitesSql);

我想循环抛出两次。

while ($row = $stmtSites->fetch()) {
[...]
}

下面几十行

while ($row = $stmtSites->fetch()) {
[...]
}

但不幸的是,第二个循环从一开始就没有循环。 所以就在第二秒之后,我必须重置声明 - 如何?像mysqli_data_seek()

一样

1 个答案:

答案 0 :(得分:0)

您不能使用fetchAll()(返回数组)吗?

$sites = $db->fetchAll($sitesSql);

然后你可以用foreach两次循环结果:

foreach ($sites as ...) {

}