0

我正在使用 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()

4

1 回答 1

0

你可以不使用fetchAll()(它返回一个数组)吗?

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

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

foreach ($sites as ...) {

}
于 2013-05-08T16:15:37.850 回答