比较两个功能。需要审核...... [英] Comparing two functions. Need review...
问题描述
全部,
我正在与功能进行比较,看看哪个是更好。更好的是,我的意思是更有效,优化,更快等等。
我已经阅读过其他主板的其他帖子,但我不是很确定
福利或者如果加速增加
,其中一个与另一个相比。
第一版
function is_active($ module){
global $ prefix,$ dbi;
$ result = sql_query(" select from web_modules
title =''$ module''",$ dbi);
list($ act)= sql_fetch_row($ result,$ dbi);
if(b) !$ result OR $ act == 0){
返回0;
}否则{
返回1;
}
}
第二版
函数is_active($ module){
global $ dbi;
静态$ save;
if(is_array($ save)){
if(isset($ save [$ module] ))return($ save [$ module]);
返回0;
}
$ result = sql_query(" select active from web_modules其中
ti tle =''$ module''",$ dbi);
while($ act = sql_fetch_row($ result,$ dbi)){
$ save [$ act [0]] = 1;
}
if(isset($ save [$ module]))return($ save [$ module]);
返回0;
}
All,
I am comparing to functions to see which is "better". In better, I mean more
efficient, optimize, faster, etc.
I have read other posts from other boards, but I''m not really sure of the
benefits or if there is a speed increase
with one vs. the other.
FIRST VERSION
function is_active($module) {
global $prefix, $dbi;
$result = sql_query("select active from web_modules where
title=''$module''", $dbi);
list ($act) = sql_fetch_row($result, $dbi);
if (!$result OR $act == 0) {
return 0;
} else {
return 1;
}
}
SECOND VERSION
function is_active($module) {
global $dbi;
static $save;
if (is_array($save)) {
if (isset($save[$module])) return ($save[$module]);
return 0;
}
$result = sql_query("select active from web_modules where
title=''$module''", $dbi);
while ($act = sql_fetch_row($result, $dbi)) {
$save[$act[0]] = 1;
}
if (isset($save[$module])) return ($save[$module]);
return 0;
}
推荐答案
模块){
global
module) {
global
前缀,
dbi;
dbi;
这篇关于比较两个功能。需要审核......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!