code: public function getNbResults()
      {
          // be smart and try to guess the total number of records
          $countQuery = $this->rewriteCountQuery($this->sql);
          if (! $countQuery) {
              // GROUP BY => fetch the whole result set and count the rows returned
              $result = $this->pdo->query($this->sql)->fetchAll();
              $count = \count($result);
  
              return $count;
          }
          if ($this->params) {
              /** @var ExtendedPdo $pdo */
              $pdo = $this->pdo;
              $sth = $pdo->prepareWithValues($this->sql, $this->params);
              $sth->execute();
              $count = $sth->fetchAll();
  
              return \count($count);
          }
          $count = $this->pdo->query($countQuery)->fetchColumn();
  
          return (int) $count;
      }
docs: {@inheritdoc}