All,
Been reading other posts on other forums, i.e. Nukecops.
My original code is this:
function is_active($modu le) {
global $prefix, $dbi;
$result = sql_query("sele ct 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;
}
}
I changed it to this:
function is_active($modu le) {
global $dbi;
static $save;
if (is_array($save )) {
if (isset($save[$module])) return ($save[$module]);
return 0;
}
$result = sql_query("sele ct 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;
}
Is the changed version "optimized" , meaning that it doesn't perform the
query if it doesn't need to ?
Thanks.
Been reading other posts on other forums, i.e. Nukecops.
My original code is this:
function is_active($modu le) {
global $prefix, $dbi;
$result = sql_query("sele ct 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;
}
}
I changed it to this:
function is_active($modu le) {
global $dbi;
static $save;
if (is_array($save )) {
if (isset($save[$module])) return ($save[$module]);
return 0;
}
$result = sql_query("sele ct 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;
}
Is the changed version "optimized" , meaning that it doesn't perform the
query if it doesn't need to ?
Thanks.