PHP Класс Pheasant\Collection

Наследование: implements IteratorAggregate, implements Countable, implements ArrayAccess
Показать файл Открыть проект

Открытые методы

Метод Описание
__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 ( )