PHP 클래스 Pheasant\Collection

상속: implements IteratorAggregate, implements Countable, implements ArrayAccess
파일 보기 프로젝트 열기: lox/pheasant

공개 메소드들

메소드 설명
__call ( $name, $args ) Magic Method, used for scopes
__construct ( $class, $query, $add = false )
__invoke ( $sql, $params = [] ) Filter function when called as a function
aggregate ( $function, $fields = null ) helpers for common aggregate functions
avg ( $field )
column ( $field ) Reduces a collection down to a single column
count ( ) Counts the number or results in the query
delete ( ) Delete all objects in a collection
filter ( $sql, $params = [] ) Adds a filter to the collection
first ( )
getIterator ( ) Returns an iterator
groupBy ( $columns ) Groups domain objects particular columns, either a single column an array. This method is additive, it won't replace previous groupBy's
hydrate ( $row ) Hydrates a row to a DomainObject
includes ( $rels ) Eager load relationships to avoid the N+1 problem
join ( $rels, $joinType = 'inner' ) Join other related objects into a collection for the purpose of filtering. Relationships is either a flat array of relationships (as defined in the object's schema) or a nested array
last ( )
limit ( $rows, $offset ) Restricts the number of rows to return
lock ( $clause = null ) Adds a locking clause to the query
max ( $field )
min ( $field )
offsetExists ( $offset )
offsetGet ( $offset ) array access
offsetSet ( $offset, $value )
offsetUnset ( $offset )
one ( ) Return one and one only object from a collection
orCreate ( $args ) Creates the passed params as a domain object if there are no results in the collection.
order ( $sql, $params = [] ) Orders the collection
orderBy ( $sql, $params = [] ) Orders the collection
query ( ) Gets the underlying query object
save ( $callback ) Applies a callback to all objects in Collection, saves them if the object has changed
select ( $fields ) Selects only particular fields
sum ( $field )
toArray ( )
unique ( ) Return only unique combinations of the domain object in the collection, e.g such as when you want only the unique objects that are the result of a join on conditions. Only columns from the primary object will be in the result.

비공개 메소드들

메소드 설명
_queryForWrite ( )

메소드 상세

__call() 공개 메소드

Magic Method, used for scopes
public __call ( $name, $args )

__construct() 공개 메소드

public __construct ( $class, $query, $add = false )
$class string the classname to hydrate
$query Query the query object
$add Closure a closure to call when an object is appended

__invoke() 공개 메소드

Filter function when called as a function
public __invoke ( $sql, $params = [] )

aggregate() 공개 메소드

helpers for common aggregate functions
public aggregate ( $function, $fields = null )

avg() 공개 메소드

public avg ( $field )

column() 공개 메소드

Reduces a collection down to a single column
public column ( $field )

count() 공개 메소드

Counts the number or results in the query
public count ( )

delete() 공개 메소드

Delete all objects in a collection
public delete ( )

filter() 공개 메소드

Adds a filter to the collection
public filter ( $sql, $params = [] )

first() 공개 메소드

public first ( )

getIterator() 공개 메소드

Returns an iterator
public getIterator ( )

groupBy() 공개 메소드

Groups domain objects particular columns, either a single column an array. This method is additive, it won't replace previous groupBy's
public groupBy ( $columns )

hydrate() 공개 메소드

Hydrates a row to a DomainObject
public hydrate ( $row )

includes() 공개 메소드

Eager load relationships to avoid the N+1 problem
public includes ( $rels )

join() 공개 메소드

Join other related objects into a collection for the purpose of filtering. Relationships is either a flat array of relationships (as defined in the object's schema) or a nested array
public join ( $rels, $joinType = 'inner' )

last() 공개 메소드

public last ( )

limit() 공개 메소드

Restricts the number of rows to return
public limit ( $rows, $offset )

lock() 공개 메소드

Adds a locking clause to the query
public lock ( $clause = null )

max() 공개 메소드

public max ( $field )

min() 공개 메소드

public min ( $field )

offsetExists() 공개 메소드

public offsetExists ( $offset )

offsetGet() 공개 메소드

array access
public offsetGet ( $offset )

offsetSet() 공개 메소드

public offsetSet ( $offset, $value )

offsetUnset() 공개 메소드

public offsetUnset ( $offset )

one() 공개 메소드

Return one and one only object from a collection
public one ( )

orCreate() 공개 메소드

Creates the passed params as a domain object if there are no results in the collection.
public orCreate ( $args )
$args array an array to be passed to the constructor via call_user_func_array

order() 공개 메소드

Orders the collection
사용 중단:
public order ( $sql, $params = [] )

orderBy() 공개 메소드

Orders the collection
public orderBy ( $sql, $params = [] )

query() 공개 메소드

Gets the underlying query object
public query ( )

save() 공개 메소드

Applies a callback to all objects in Collection, saves them if the object has changed
public save ( $callback )

select() 공개 메소드

Selects only particular fields
public select ( $fields )

sum() 공개 메소드

public sum ( $field )

toArray() 공개 메소드

public toArray ( )

unique() 공개 메소드

Return only unique combinations of the domain object in the collection, e.g such as when you want only the unique objects that are the result of a join on conditions. Only columns from the primary object will be in the result.
public unique ( )