Active
Project:
Ajax Table
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Aug 2008 at 08:35 UTC
Updated:
25 Aug 2008 at 08:36 UTC
I have discovered it doesn't get the number of rows correctly when the query contains "GROUP BY" and "SUM()"; so I had to change some code:
$count_inner = '*';
if ($table['count_query'] != '') {
$count_inner = $table['count_query'];
}
$count_query = preg_replace('/SELECT (.*) FROM/','SELECT COUNT(' . $count_inner . ') FROM',$table['query']);
$result = db_query($count_query,$search_values);
$row = db_fetch_array($result);
$count = $row['COUNT(' . $count_inner . ')'];
$elements['rows'] = $count;
replaced by
<?
$res_temp=db_query($table["query"]);
$count=db_num_rows($res_temp);
$elements['rows']=$count;
unset($res_temp);
?>
It may add some overhead to the database server, but it has less PHP code and works.
Comments
Comment #1
enboig commentedsorry, my code wasn't included in php tags correctly: