本文介绍了如何倒带PDO结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道之前曾有人问过这个问题,但是我尝试了Eveything,却找不到它的工作方式. 我有一个准备好的查询,我需要通过两个while()循环使用它两次:
I know this question has been asked before, but I tried eveything and can't find how it works. I have a prepared query, and I need to use it twice with two while() loops like this:
$query = $pdo->prepare('SELECT ...'); $query->execute(); while( $results = $query->fetch() ){ // instructions } // rewind while( $results = $query->fetch() ){ // instructions }谢谢
推荐答案就像在第一次迭代中获得所有结果并在第二次循环时一样简单:
Could be as simple as getting all the results on the 1st iteration and loop on the 2nd:
$res = array(); while( $results = $query->fetch() ){ $res[] = $results; // instructions } foreach($res as $results){ // instructions }更多推荐
如何倒带PDO结果?
发布评论