This topic is locked

List page: Get Row Count

12/10/2024 6:20:20 PM
PHPRunner General questions
D
DRCR Dev author

I'm trying to use the List page: Get Row Count feature in the list page, but the help section speaks of using something like:

return 100; to get a row count, however the

return 100;

does't stop the row count query or change the row value on the list page.

I need the new syntax to make this work. I store the row counts of tables with lots of rows in another table and just need to use it and optimise the:

"select count() from (select" query from the every list page. I don't want to enable "disable counting the number of rows (faster) feature" I just need to optimise the row count query.

M
max benelli 12/16/2024

+1

D
DRCR Dev author 12/16/2024

I had worked 19 hours when I wrote that. Lets rephrase:

Every list page counts the rows eg: Displaying 1 - 40 of 359445

  1. Instead of doing ANOTHER long second count, how do I just get the value that has ALREADY been counted, without doing ANOTHER COUNT query.


  2. What is the actual syntax for List page: Get Row Count. The decreciated information in the help doesn't make sense, I don't understand what List page: Get Row Count is trying to achieve. I'm hoping this section allows me to write my own effiencient row count, save it, reuse it and, kill the PHPRUNNER row count.



C
cristi 12/16/2024

In the golden words of Sergey Kornilov:

The purpose of GetRowCount event is to perform your own row count calculation. If you need to perform some complicated filtering, GetRowCount is the placed where you calculated the current number of records and return it.
Since number of records variable appears in Visual Editor as "records_found" you can use the following BeforeDisplay event:
echo $xt->getvar("records_found");

Why are you even consider using it?
Why not:

var records = pageObj.getAllRecords(); //fetch all records displayed on page
records.forEach( function( row, idx ) {
//do a count here
});
Sergey Kornilov 12/16/2024

I just want to chime in to explain what Deprecated means. It basically means do not use as it may stop working after some new update. For instance, in version 11 we are retiring some old deprecated APIs like DAL.

As the manual suggests, a better way to handle this situation is to use SQL View where you are in a full control of all SQL queries you need to run.
https://xlinesoft.com/phprunner/docs/get_row_count.htm