0

I'm using drupal pagination here i have add some part of my code pagination is working perfect while I'm trying to get the total no of record it is always displaying 10. As i understand i have set the limit 10 so it displaying only total 10

$query->orderBy('r.published_date', 'DESC');
        $pager = $query->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(10);
    $results = $pager->execute()->fetchAll();

This $results variable I'm getting data with the set of 10 values.

I would like to display total no of data for that i have created other variable where i have directly executed query in $result so it could give total no of records but its not working it displaying only 10

$result = $query->execute();
        while($data = $result->fetchObject()){
           $count_ret[]=$data->published_date;
        }
             $total=count($count_ret);

please guide me where i'm doing wrong

1 Answer 1

0

Until the issue Convert pager.inc to a service is solved you find the pager information still in global variables:

global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;

$count_of_total_records = $pager_total_items[$element];

Where $element defaults to '0' if this is the first pager with no element id set.

1
  • Thanks i was using like this global $pager_total_items; global $pager_total; echo $pager_total; echo $pager_total."hiiii"; Jul 17, 2018 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.