gpt4 book ai didi

php - 运行结果集时的效率

转载 作者:行者123 更新时间:2023-12-01 00:28:23 24 4
gpt4 key购买 nike

在遍历结果集时,与其他方法相比,这种方法的效率如何?

for ($iCont=0; $iCont < mysql_num_rows($this->rsQuery); $iCont++)
{
mysql_data_seek($this->rsQuery,$iCont);
$row=mysql_fetch_assoc($this->rsQuery);
//more things here like write row or push it to a global array
}

使用mysql_data_seek是否有任何效率问题,即使它是按顺序完成的?

开头的mysql_num_rows()怎么样?有影响吗?

那么,还有更好的方法吗?

我想要实现的是一种方法,用于返回一个包含所有结果集内容的关联数组,另一种方法用于使用数据创建一个网格(html 表格)。

谢谢

最佳答案

我不确定这样效率更高但看起来更好

while ($row = mysql_fetch_assoc($this->rsQuery))
{
//do your thing here
}

关于php - 运行结果集时的效率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9837558/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com