PHP / SQL:ORDER BY或排序($数组)? [英] PHP/SQL: ORDER BY or sort($array)?
本文介绍了PHP / SQL:ORDER BY或排序($数组)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你认为哪是一个PHP脚本更快:
$查询=SELECT ... FROM ... ORDER BY first_val
或
而($行= odbc_fetch_array($结果))
$ arrayName中的[] =数组(
first_key=> $行['first_val'],
second_key=> $行['second_val'],
等等...
);
排序($ arrayName中);
解决方案
这取决于很多因素,我甚至不知道该怎么开始。
不过,按照惯例,在执行排序数据库身边。
索引,排序规则而这一切,他们帮助。
Which do you think is faster in a PHP script:
$query = "SELECT... FROM ... ORDER BY first_val";
or
while($row = odbc_fetch_array($result))
$arrayname[] = array(
"first_key" => $row['first_val'],
"second_key" => $row['second_val'],
etc...
);
sort($arrayname);
解决方案
It depends on so many factors that I don't even know what to begin with.
But as a rule, you perform sorting on database side.
Indexes, collations and all this, they help.
这篇关于PHP / SQL:ORDER BY或排序($数组)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文