This topic is locked
[SOLVED]

 Totals over whole table

2/2/2016 10:32:19 AM
PHPRunner General questions
W
wpl author

Hello Listers,
maybe someone can point me into the right direction for the following task. The "Total:" offered in the "Totals" section of PHPRunner shows a total (or count or average) for the actual page only.

What I would like to achieve is: have a total or count over the whole table instead, on the bottom of the list page. However, this total should reflect any search or filter condition applied to the table.

BTW, I know how to insert template vars in Visual Editor and how to populate them in BeforeDisplay event (as shown eg in Calculating Two Totals on list page).
Regards

Sergey Kornilov admin 2/2/2016

This is a job for code snippet where you can execute SQL query and calculate total for the whole table. You have access to the current WHERE clause in events links BeforeSQLQuery:

http://xlinesoft.com/phprunner/docs/before_sql_query.htm

W
wpl author 2/3/2016

Sergey,
thanks for this suggestion which will work fine when dealing with a plain table. On my table, there are some JOINS and filtering/searching will also be done on JOINed fields.

Where would I have to I grab the JOIN-Part of the respective query to solve this?
Thanks again

Sergey Kornilov admin 2/3/2016

I don't understand. You are adding this functionality to some specific table where you do know the whole SQL query as it appears on 'SQL Query' screen. Just copy your SQL Query from there.

W
wpl author 2/3/2016



I don't understand. You are adding this functionality to some specific table where you do know the whole SQL query as it appears on 'SQL Query' screen. Just copy your SQL Query from there.


Sergey,
thanks. Well, I can do that, of course. Just thought I could avoid copy/paste here (and, especially having to remember to account for changes in the underlying SQL-Query) by accessing something in "the guts" of PHPRunner ;-).
Regards

Sergey Kornilov admin 2/3/2016

If you check the same event you can find SQL query parameter there as well:

http://xlinesoft.com/phprunner/docs/before_sql_query.htm