Get total number of rows

@return  int
@since   2.0.0
197832
public function total()
	{
		// Note that we do not need to parse includes at this stage, as includes do not effect
		// the primary result set, and thus do not effect the count. whereRelated() could effect
		// the count, but that method is not currently in use.
		//
		// We also reset the 'select' clause to avoid pulling unnecessary records and reset
		// the 'order by' clause to avoid referenced fields in the aforementioned 'select' clauses
		// that mgiht have been removed. Neither of these should have any effect on a count.
		$first = $this->deselect()
		              ->select($this->getQualifiedFieldName($this->getPrimaryKey()), 'count', true)
		              ->unordered()
		              ->rows(false)
		              ->first();
		              //->count;

		$total = $first ? (int)$first->count : 0;

		$this->reset();

		return $total;
	}
634483
public function num_rows($sqlQuery = false)
    {
        $sql = $this->buildQuery('select');
        if($sqlQuery === true) {
            return $this->getQuery();
        }
        $result = $this->executeQuery($sql);
        return $result->num_rows;
    }
431959
public function fetched_count()
    {
        if ($this->statement) {
            return $this->statement->num_rows;
        }
        
        if (!$this->mysqli_result) {
            $this->last_error_id = "db_result_error";
            return false;
        }
        
        // by update, insert, delete it is not an object
        // by select it is an object
        // crazy!
        
        if (!is_object($this->mysqli_result)) {
            return false;
        }
        
        return $this->mysqli_result->num_rows;
    }
876995
public function getRowCount() {
    $mapper = ObjectFactory::getInstance('persistenceFacade')->getMapper($this->type);
    if ($this->table) {
      $table = !is_array($this->table) ? $this-> table : key($this->table);
      // use pk columns for counting
      $countColumns = array_map(function($valueName) use ($mapper, $table) {
        return $mapper->quoteIdentifier($table).'.'.$mapper->quoteIdentifier($mapper->getAttribute($valueName)->getColumn());
      }, $mapper->getPkNames());
    }
    else {
      // fallback if table is not defined: take first column
      $adapter = $this->getAdapter();
      $columns = $this->processSelect($adapter->getPlatform());
      $countColumns = [$columns[$this->quantifier ? 1 : 0][0][0]];
    }

    $countStatement = clone $this;
    $countStatement->reset(Select::COLUMNS);
    $countStatement->reset(Select::LIMIT);
    $countStatement->reset(Select::OFFSET);
    $countStatement->reset(Select::ORDER);
    $countStatement->reset(Select::GROUP);
    // remove all join columns to prevent errors because of missing group by for non aggregated columns (42000 - 1140)
    $joins = $countStatement->joins->getJoins();
    $countStatement->reset(Select::JOINS);
    foreach ($joins as $key => $join) {
      // re add join without cols
      $countStatement->join($join["name"], $join["on"], [], $join["type"]);
    }

    // create aggregation column
    $countStatement->columns(['nRows' => new \Zend\Db\Sql\Expression('COUNT('.$this->quantifier.' '.join(', ', $countColumns).')')]);

    $countStatement->id = $this->id != self::NO_CACHE ? $this->id.'-count' : self::NO_CACHE;
    try {
      $result = $countStatement->query();
      $row = $result->fetch();
      return $row['nRows'];
    }
    catch (\Exception $ex) {
      self::$logger->error("The query: ".$countStatement->__toString()."\ncaused the following exception:\n".$ex->getMessage());
      throw new PersistenceException("Error in persistent operation. See log file for details.");
    }
  }
1118176
public function rowCount()
    {
        if (!$this->_adapter) {
            return false;
        }
        $mysqli = $this->_adapter->getConnection();
        return $mysqli->affected_rows;
    }
1187914
public function count()
    {
        if ($this->rows_count == null) {
            $this->rows_count = $this->result->countRows();
        }

        return $this->rows_count;
    }
1298104
public function row()
    {
        if (isset($this->rows[$this->cursor])) {
            return $this->rows[$this->cursor++];
        }

        return false;
    }
554459
public function count(): int
    {
        $result = $this->getCountQuery()->fetchFirst();

        if ($result === null) {
            return 0;
        }

        return (int)$result['total'];
    }
1033479
public function getTotalCount(): int
    {
        if (null === $this->totalRecords) {
            if ($this->getCountMethod() === self::COUNT_METHOD_QUERY) {
                $this->totalRecords = $this->getTotalRecordsByQueryCount();
            } elseif ($this->getCountMethod() === self::COUNT_METHOD_SELECT) {
                $this->totalRecords = $this->getTotalRecordsBySelectCount();
            } elseif ($this->getCountMethod() === self::COUNT_METHOD_RECORDCOUNT) {
                $this->totalRecords = $this->getTotalRecordsByRecordCount();
            } else {
                throw new \LogicException('Cannot get a method to obtain the total count');
            }
        }
        return $this->totalRecords;
    }
1047018
public function count()
    {
        if (empty($this->queryString)) {
            $builder = clone $this->builder;
            $builder->resetQueryPart('orderBy');
            $stmt = $builder->execute();
        } else {
            $stmt = $this->connection->executeQuery($this->queryString, $this->queryParams);
        }

        return (int) $stmt->rowCount();
    }
814635
public function rowCounts()
    {
        if (!$this->rowCounts) {
            foreach ($this->data['resultSets'] as $resultSet) {
                $this->rowCounts[] = $resultSet['stats']['rowCountExact'];
            }
        }

        return $this->rowCounts;
    }
628552
public function getTotalItemCount()
    {
        if ($this->rowCount !== null) {
            return $this->rowCount;
        }

        $param = null;

        if (is_array($this->select)) {
            $select = $this->select[0];
            $param = $this->select[1];
            $adt = $this->sql->getAdapter();

            $statement = $adt->query(sprintf("SELECT COUNT(1) AS c FROM (%s) AS original_select", $select), $adt::QUERY_MODE_PREPARE);
        } else {
            $select = clone $this->select;
            $select->reset(Select::LIMIT);
            $select->reset(Select::OFFSET);
            $select->reset(Select::ORDER);

            $countSelect = new Select();
            $countSelect->columns(array('c' => new Expression('COUNT(1)')));
            $countSelect->from(array('original_select' => $select));

            $statement = $this->sql->prepareStatementForSqlObject($countSelect);
        }

        $result = $statement->execute($param);
        $row = $result->current();

        $this->rowCount = $row['c'];

        return $this->rowCount;
    }
695417
public function getCountAll()
    {
        if ($this->sync && $this->countAll !== null) return $this->countAll;
        
        $query = clone $this->query;
        $query->resetQueryPart('orderBy')
              ->setMaxResults(null)
              ->setFirstResult(null)
              ->select('COUNT(1)');
			  
        $this->fixWhere($query);
                            
        $stmt = $query->execute();  
        if ($stmt->rowCount() > 1) {
            $this->countAll = $stmt->rowCount();
        } 
        else {
            $this->countAll = $stmt->fetchColumn();
        }
        
        return $this->countAll;  
    }
130408
public function totalPages()
    {
        $maxrows      = (($m = $this->getParameter('RowsPerPage')) !== null)?$m:$this->getLocal('MaxRows');
        $totalrecords = (($m = $this->getParameter('TotalRecords')) !== null)?$m:$this->getLocal('TotalRecords');

        if (empty($totalrecords))
            return 0;
        if(empty($maxrows))
            throw new FiltererException('filter \'paging-total-pages\' requires the MaxRows template variable to be set');

        $totalpages = intval(($totalrecords-1)/$maxrows)+1;

        return $totalpages;
    }
89127
public function num_rows()
	{
		return is_int($this->num_rows)
			? $this->num_rows
			: $this->num_rows = @sqlite_num_rows($this->result_id);
	}
991295
private function count()
    {
        $qb = clone $this->queryBuilder;
        $this->resetSqlParts($qb, ['orderBy'])
            ->setFirstResult(null)
            ->setMaxResults(null);
        $connection = $qb->getConnection();
        $sql = sprintf("SELECT COUNT(*) FROM (%s) _sps_cnt_", $qb->getSQL());
        $stmt = $connection->executeQuery($sql, $qb->getParameters(), $this->parametersTypes);
        $this->totalResultCount = $stmt->fetchColumn();

        return $this->totalResultCount;
    }
939193
public function count() {
        $sql    = $this->getSQL();
        $values = $this->values;
        if ($sql) {
            try {
                $statement = $this->dialect->prepare($sql);
                foreach ($values as $value) {
                    list ($name, $val, $type) = $value;
                    if (!$statement->bindValue($name, $val, $type)) {
                        $this->errorSQL    = $sql;
                        $this->errorValues = $values->__toString();
                        $this->error       = 'can not bind the value ' . $val . '[' . $type . '] to the argument:' . $name;

                        return false;
                    }
                }
                $rst = $statement->execute();
                $cnt = false;
                if ($rst) {
                    $cnt = $statement->rowCount();
                } else {
                    $this->dumpSQL($statement);
                }
                if ($statement) {
                    $statement->closeCursor();
                    $statement = null;
                }
                QueryBuilder::addSqlCount();

                return $cnt;
            } catch (\PDOException $e) {
                $this->exception   = $e;
                $this->error       = $e->getMessage();
                $this->errorSQL    = $sql;
                $this->errorValues = $values->__toString();

                return false;
            }
        } else {
            $this->error       = 'Can not generate the delete SQL';
            $this->errorSQL    = '';
            $this->errorValues = $values->__toString();
        }

        return false;
    }