Gets the constrained count

@param   int     $count     The count to limit by
@param   string  $operator  The comparison operator used between the column and the count
@return  array
@since   2.0.0
358549
public function getConstrainedKeysByCount($count, $operator = '>=')
	{
		$relatedKey = $this->relatedKey;

		return $this->getConstrainedKeys(function($related) use ($count, $relatedKey, $operator)
		{
			$related->group($relatedKey)->having('COUNT(*)', $operator, $count);
		});
	}
584038
public static function countWhere (string $column, array $operatorValue, string $joinOperator="AND") : int
	{
		$joinOperator 	= static::validateOperator($joinOperator, "AND");
		$expression 	= static::generateValue($column, $operatorValue, $joinOperator);
		$sqlQuery  		= "SELECT COUNT(*) as count FROM ".static::$tableName." WHERE {$column} {$expression}";
		$resultSet 		= Database::getInstance()->query($sqlQuery);
		$row 			= Database::fetchAssoc($resultSet);
		return (int) array_shift($row);
	}
420885
public static function findByColumn (string $column, array $operatorValue, string $joinOperator="AND", int $limit=1)
	{
		$joinOperator 	= static::validateOperator($joinOperator, "AND");
		$expression 	= static::generateValue($column, $operatorValue, $joinOperator);
		$sqlQuery  		= "SELECT * FROM ".static::$tableName." WHERE {$column} {$expression}";
		return static::limitFindBySql($sqlQuery, $limit);
	}
404804
public function readRecords($count = 10)
    {
        $result = $this->getRecords($this->offset, $count);
        $this->offset += count($result);

        return $result;
    }
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.");
    }
  }
934598
public function count()
	{
		//get the limit clause value
		$limit = $this->limits;

		//get the offset value
		$limitOffset = $this->offset;

		//get the fields clause
		$fields = $this->fields;

		//compose the fields array
		$this->fields = array($this->froms => array("COUNT(1)" => "rows"));

		//set limit to 1
		$this->limit(1);

		//get the first row
		$row = $this->first()->result_array();

		//set the value of the fields
		$this->fields = $fields;

		//check if fields is defined
		if ( $fields ) 
		{
			//set the value o fields
			$this->fields = $fields;

		}

		//check if the limit value is set
		if ( $limit ) 
		{
			//set the value of limit
			$this->limits = $limit;

		}

		//check if the limit offset value is defined
		if ( $limitOffset ) 
		{
			//set the offset value
			$this->offset = $limitOffset;

		}

		//get the response object instance
		$this->responseObject 
			->setNumRows($row[0]['rows'])
			->setResultArray($row);

		//return the full response object
		return $this->responseObject;

	}
94943
public function limit($count = null, $offset = null)
    {
        $this->_parts[self::LIMIT_COUNT]  = (int) $count;
        $this->_parts[self::LIMIT_OFFSET] = (int) $offset;
        return $this;
    }
1355534
public function Count($Operation) {
      $this->Permission('Garden.Moderation.Manage');

      if ($Operation == 'edits')
         $Operation = array('edit', 'delete');
      else
         $Operation = explode(',', $Operation);
      array_map('ucfirst', $Operation);

      $Count = $this->LogModel->GetCountWhere(array('Operation' => $Operation));

      if ($Count > 0)
         echo '<span class="Alert">', $Count, '</span>';
   }
539406
public function where($column, $operator, $value, $filter = false)
    {
        return $this->constraint(__FUNCTION__, $column, $operator, $value, $filter);
    }
415254
public function limit($sql, $count, $offset = 0)
    {
       $this->_connect();
       return $this->_serverType->limit($sql, $count, $offset);
    }
578317
final public function limit(int $offsetOrCount, int $count = null)
    {
        if ($count === null) {
            $this->limit['offset'] = 0;
            $this->limit['count']  = $offsetOrCount;
        } else {
            $this->limit['offset'] = $offsetOrCount;
            $this->limit['count']  = $count;
        }

        return $this;
    }
1371264
function Count($where = null) {
		$this->LoadSchema();
		if ($this->UseCache('count')) {
			$cacheid = md5(json_encode($where));

			if ($value = $this->GetCache('count', $cacheid))
				return $value;
		}

		$this->ResetQuery(array(
			'method' => 'count',
			'table' => $this->table,
			'where' => $where,
		));

		$this->Trigger('access', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('pull', $where);
		if (!$this->continue)
			return 0;

		$this->Trigger('getall', $where);
		if (!$this->continue)
			return 0;

		$this->db->select('COUNT(*) AS count');
		$this->db->from($this->table);
		if ($where = $this->FilterFields($where, 'where'))
			$this->db->where($where);
		$row = $this->db->get()->row_array();
		if (!$this->continue)
			return 0;

		return isset($cacheid) ? $this->SetCache('count', $cacheid, $row['count']) : $row['count'];
	}
132085
public static function count($where)
     {
         $self = self::instance();
         $rows = new ModelArray();
         //
         $sql = 'select count(*) as cnt from '.$self->DBtable." where $where ";
         $data = Database::read($sql, 1);
         //
         return $data[0]['cnt'];
     }
407858
public function take(int $count): Observable
    {
        if ($count === 0) {
            return self::empty();
        }

        return $this->lift(function () use ($count) {
            return new TakeOperator($count);
        });
    }
785332
public function limit( $count = null ) {
			
			if ( null === $count || is_int( $count ) ) {
			
				if ( null !== $count && $count >= 0 ) {
					
					return $count === $this->len
						? $this
						: new static( array_slice( $this->items, 0, $count ) );
				
				} else
				if ( $many === null || $many === -1 ) {
				
					return $this;
				
				} else {
				
					throw new \browserfs\Exception('Invalid argument $count: Expected int[-1..length] | null' );
				
				}
			} else {

				throw new \browserfs\Exception('Invalid argument $count: Expected int[-1..length] | null');
			
			}

		}
144796
function limit( $count, $offset = null ) {

        if ( $this->parent_ ) {

            throw new \LogicException( 'Cannot limit referenced result' );

        }

        $clone = clone $this;

        $clone->limitCount = $count;
        $clone->limitOffset = $offset;

        return $clone;

    }
289939
private function read($count) {
        $count = abs($count);

        if ($count > 0) {
            return fread($this->STREAM, $count);
        }

        return NULL;
    }