如何倒带PDO结果?

编程入门 行业动态 更新时间:2024-10-24 10:16:50
本文介绍了如何倒带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结果?

本文发布于:2023-07-11 09:12:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093537.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PDO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!