Pagination Widget when using custom Database query

webbusteruk 26 Jan, 2019
We are using a custom PHP query to select from a database.

However, the pagination widget does not seem to work when using custom PHP function to query database instead of the read_data function. Are we missing something that the paginator need to work?
healyhatman 26 Jan, 2019
If you're using v6 you'll need
LIMIT $this->data("startat"), $this->data("limit")
in your query.
webbusteruk 26 Jan, 2019
Sorry, should have been clearer. This is part of our php code:
// get limit and startat from paginator
$limit= $this->data('limit');
$startat= $this->data('startat');

// if limit and startat selected, apply to query
$limit = (isset($limit)) ? $limit : '10';
$limitf= (!empty($limit)) ? "LIMIT ". $limit : "";
$startat= (!empty($startat)) ? "OFFSET ". $startat : "";

//part of query
$query = "SELECT * FROM database ORDER BY aid DESC " . $limitf . $startatf;
The paginator only shows the filter icon, but no 'page numbers' (navigation) despite changing the limit. It results in the remaining rows after the limit to not be shown.

Could part of the issue might be that we have 2 other read_data functions on the same event? Setting the limit for the other read_data seems to make the page numbers appear. However, even if all other read_data functions are deleted, the paginator still do not show page numbers for the php code query.
webbusteruk 26 Jan, 2019
If there are multiple database queries, how does the paginator determine which database query is used to display how many pages there are?
healyhatman 26 Jan, 2019
Disable pagination on the data read that doesn't require pagination
webbusteruk 29 Jan, 2019
Disabling pagination on other read_data resulted in the paginator widget having no data to determine pages. This presumably is because the paginator obtains the data (ie, number of rows) from read_data functions.

However when using custom php sql query (in place of read_data), the paginator is not able to obtain the number of rows. I'm thinking the read_data must have output another variable to the paginator, but I can't seem to find what this is.

Does anyone know where the code for paginator widget is within the directory?

Edit: Figured out a clue from the debug. When pagination is enabled, read_data has another variable at the start of its query.
   [read_data] => Array
(
[log] => Array
(
[0] => SELECT COUNT(`model`.`aid`) AS `model.count` FROM `site_chronoforms_data_test2` AS `model`;
Now I just have to figure out how to pass this from my php sql query to the paginator widget ...
webbusteruk 06 Feb, 2019
In case anyone is wondering, we've decided it's far easier (and more customisable) to just create our own pagination php script from scratch.

If anyone wants an example of our code just reply here (as it'll take some time to 'clean' it up to be posted on the forums - if there's no demand for it we won't bother).
This topic is locked and no more replies can be posted.