I am having trouble using Group BY in my grid SELECT statement. It seems to work but I get spurious parts of the query appearing at the top of my output page such as: GROUP BY `downloadyear` , `downloadmonthnumber` DESC ORDER BY `downloadyear` DESC
I have tried using a view (tested and working):
$g->select_command = "SELECT * FROM vw_countdownloadsbymonth";
and I have tried putting the code directly into the grid as:
$g->select_command = " SELECT
YEAR(`tbldownloadhistory`.`downloaddate`) AS `downloadyear`,
MONTH(`tbldownloadhistory`.`downloaddate`) AS `downloadmonthnumber`,
MONTHNAME(`tbldownloadhistory`.`downloaddate`) AS `downloadmonth`,
COUNT(`tbldownloadhistory`.`idtbldownloadhistory`) AS `numberofdownloads`
FROM
`tbldownloadhistory`
WHERE
(NOT (`tbldownloadhistory`.`downloadIP` IN (SELECT
`tblexcludeip`.`excludeip`
FROM
`tblexcludeip`)))
GROUP BY `downloadyear` , `downloadmonthnumber`";
But the results are the same with the strange text being displayed on my web page. Does using Group By in the query cause problems with the grid?
Any suggestions please?
Thanks,
Cliff
Make sure, you call '$g->render();' function before any HTML is rendered
(echo'd) to output, as it expect exact JSON format for ajax calls. You can echo the output of render() function to desired location in html.