// create as member of class CreateLayout
// and call function...
private function sql_records_num ($widget) {
global $db;
// void the numerous SELECT count(id)
if ( strncasecmp($widget->normal_select,"select count(",13)==0) {
return 1;
}
// correct BUG for GROUP [HAVING], AS, LIMIT.
if ( stristr ( $widget->normal_select, " GROUP " )!== false ||
stristr ( $widget->normal_select, " AS " ) !== false ||
stristr ( $widget->normal_select, " LIMIT ") !== false ) {
$db->get_results($widget->normal_select);
return $db->num_rows;
}
preg_match('/select DISTINCT(.*)from/i', $widget->normal_select,
$get_DISTINCT);
preg_match('/select (.*)from/i' , $widget->normal_select,
$selectionmatch);
if (isset($selectionmatch['1'])){
if (isset ($get_DISTINCT['1'])){
$mysql_count = ' count(DISTINCT('.$get_DISTINCT['1'].')) ';
}else{
$mysql_count = ' count(*) ';
}
$records_num_query = str_replace($selectionmatch['1'], $mysql_count,
$widget->normal_select);
//RG1024. original don't include ASC.
$records_num_query = preg_replace('/ORDER BY(.*)( DESC| ASC)?/i', '',
$records_num_query);
$records_num = $db->get_var($records_num_query);
return $records_num;
}
// return 0 not '' ok?
return 0;
}
--
You received this bug notification because you are a member of Aiki
Framework Admins, which is subscribed to aikiframework.
https://bugs.launchpad.net/bugs/736257
Title:
aiki always run a query to count the records, need different solution
Status in Aiki Framework:
In Progress
Bug description:
in widgets.php code between 375 and 386 should be replaced
_______________________________________________
Mailing list: https://launchpad.net/~aikiframework.admins
Post to : aikiframework.admins@lists.launchpad.net
Unsubscribe : https://launchpad.net/~aikiframework.admins
More help : https://help.launchpad.net/ListHelp