Hi,
i'm using quiet a lot of complex SQL statements, especially to create overview summaries. These queries quite often contain one or more joins over different tables and do contain "group by" statements on calculated fields (mostly SQL SUM fields); eg:
"Select pm_projects.projid, pm_domains.pdomain, pm_projects.title, pm_projects.typeid, pm_customers.custname, pm_projects.budgetf, pm_projects.closed, SUM(pm_invoices.rvalue), pm_projects.budgetf As pl1, pm_projects.budgetf As pl2
From pm_invoices Inner Join pm_projects ON pm_invoices.projid = pm_projects.projid Inner Join pm_customers on pm_projects.custid = pm_customers.custID Inner Join pm_domains on pm_projects.pdomain=pm_domains.pdomainid
Where pm_projects.ordered=1
Group By pm_projects.projid"
The number of records returned by the functions 'GetRowCount' and 'gSQLRowCount' are not correct. My guess is that there is an interference between the count() and the SUM clause in when running the SQL in these functions.
I've currently bypassed this problem by running the real full query in the above functions, and returning the number of records found (db_numrows). I know this is less perfomant on large datasets, but it does return the correct number of records found. I've modified this in the phpRunner/source implementation of 'commonfunctions' to maintain this fix on rebuilding projects.
I suggest either to choose for the 'safe' way and perform the full query in the above functions, or to have a proper, non-conflicting count() implementation (or either a combination of both). Unfortunately I do not have the time myself (yet) to re-implement the functions.
Regards
Stefan