2011-02-14 71 views
0

这是我的MySQL查询:

SELECT item_to_list_tb . * , item_tb . * , list_tb . * 
FROM item_to_list_tb, item_tb, list_tb 
WHERE item_to_list_tb.list_id =3 
AND item_to_list_tb.item_id = item_tb.item_id 
GROUP BY item_to_list_tb.item_id 
ORDER BY item_to_list_tb.item_ord 
LIMIT 0 , 30 

它需要0.008秒时直接在MySQL数据库上。

然而,当我得到的结果在PHP中,如果我使用

$result = mysql_query($sql, $this->svr_msconnect); 
mysql_fetch_array($result, MYSQL_ASSOC)); 

它需要4秒加载!

然而,当我使用

$result = mysql_query($sql, $this->svr_msconnect); 
mysql_fetch_row($result); 

需要定期0.008秒左右。

据我所知,mysql_fetch_row的con是它不给列的名称。是对的吗?这意味着我无法回显$r['col_name']之类的内容,而是需要使用类似$r[0][3]之类的内容。是对的吗?

还有什么替代方法?

+0

肯定不是mysql_fetch_array问题。你必须进行更多的调查 – 2011-02-14 18:13:24

回答

2

尝试mysql_fetch_assoc($result);

下面照会:php.net

注:业绩 要注意的重要一点是,使用mysql_fetch_assoc()比使用和mysql_fetch_row显著慢( ),同时它提供了显着的附加价值。