2012-03-23 17 views
0

運行結果集時,與其他方法相比,此方法的效率如何?通過結果集運行時的效率

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表格)。

謝謝

回答

3

我不知道它這是更有效,但外觀更好

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

由於mysql_fetch_assoc返回一行或零如果沒有返回更多的行,一個簡單的while循環是必須的:

while($row = mysql_fetch_assoc($this->rsQuery)) { 
// ... 
} 
相關問題