PHP Class TORM\Collection

PHP version 5.5
Author: Eustáquio Rangel ([email protected])
Inheritance: implements Iterator
Show file Open project: taq/torm

Public Properties

Property Type Description
$page
$per_page

Public Methods

Method Description
__call ( string $method, mixed $args ) : method Call a method
__construct ( mixed $builder, mixed $vals, string $cls ) Constructor
avg ( string $attr ) : mixed Return collection attribute average
count ( ) : integer Return collection row count
current ( ) : mixed Return current value
destroy ( ) : destroyed Destroy collection records
key ( ) : mixed Return current key
limit ( integer $limit ) : mixed Define row limit
max ( string $attr ) : mixed Return collection attribute maximum value
min ( string $attr ) : mixed Return collection attribute minimum value
next ( ) : mixed Return the next collection object
order ( integer $order ) : mixed Define row order
paginate ( integer $page, integer $per_page = 50 ) : mixed Return collection pagination page
rewind ( ) : null Rewind collection
sum ( string $attr ) : mixed Return collection attribute sum
toArray ( string $limit ) : mixed Convert collection to an array
updateAttributes ( string $attrs ) : updated Update collection attributes
valid ( ) : boolean Return if its valid

Private Methods

Method Description
_executeAndReturnFirst ( mixed $builder, mixed $vals ) : mixed Return the first value
_getCurrentData ( ) : mixed Get the next result from collection
_makeBuilderForAggregations ( mixed $fields ) : mixed Construct builder for aggregations

Method Details

__call() public method

Call a method
public __call ( string $method, mixed $args ) : method
$method string to call
$args mixed arguments to send
return method return

__construct() public method

Constructor
public __construct ( mixed $builder, mixed $vals, string $cls )
$builder mixed builder object
$vals mixed values
$cls string class

avg() public method

Example: echo Person::all()->avg("age");
public avg ( string $attr ) : mixed
$attr string attribute
return mixed average

count() public method

Example: echo Person::all()->count();
public count ( ) : integer
return integer row count

current() public method

Return current value
public current ( ) : mixed
return mixed value

destroy() public method

Example: Person::all()->destroy();
public destroy ( ) : destroyed
return destroyed or not

key() public method

Return current key
public key ( ) : mixed
return mixed key

limit() public method

Define row limit
public limit ( integer $limit ) : mixed
$limit integer row limit
return mixed this object

max() public method

Example: echo Person::all()->max("age");
public max ( string $attr ) : mixed
$attr string attribute
return mixed maximum

min() public method

Example: echo Person::all()->min("age");
public min ( string $attr ) : mixed
$attr string attribute
return mixed minimum

next() public method

Example: echo Person::all()->next();
public next ( ) : mixed
return mixed object

order() public method

Define row order
public order ( integer $order ) : mixed
$order integer row order
return mixed this object

paginate() public method

Example: echo Person::all()->paginate(1, 25);
public paginate ( integer $page, integer $per_page = 50 ) : mixed
$page integer current page
$per_page integer rows per page
return mixed this object

rewind() public method

Rewind collection
public rewind ( ) : null
return null

sum() public method

Example: echo Person::all()->sum("age");
public sum ( string $attr ) : mixed
$attr string attribute
return mixed sum

toArray() public method

Example: echo Person::all()->toArray();
public toArray ( string $limit ) : mixed
$limit string -1 to all collection, otherwise the number of elements
return mixed average

updateAttributes() public method

Example: echo Person::all()->updateAttributes("age", 25);
public updateAttributes ( string $attrs ) : updated
$attrs string attributes
return updated or not

valid() public method

Return if its valid
public valid ( ) : boolean
return boolean valid

Property Details

$page public property

public $page

$per_page public property

public $per_page