PHP Класс LazyRecord\BaseCollection

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

Открытые свойства

Свойство Тип Описание
$_readQuery
$selected
$yamlExtension

Защищенные свойства (Protected)

Свойство Тип Описание
$_alias
$_lastSql
$_postCreate postCreate hook.
$_presetVars preset vars for creating.
$_result operation result object.
$_rows array handle data for items.
$_schema
$_vars
$defaultOrdering $this->defaultOrdering = array( array( 'id', 'desc' ), array( 'name', 'desc' ), );.
$explictSelect
$handle handle
$preferredTable

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

Метод Описание
__call ( $m, $a ) Dispatch undefined methods to SelectQuery object, To achieve mixin-like feature.
__clone ( ) When cloning collection object, The resources will be free, and the query builder will be cloned.
__construct ( )
__toString ( )
add ( BaseModel $record )
asPairs ( string $key, string $valueKey ) Return pair array by columns.
count ( ) This method implements the Countable interface.
create ( array $args ) : mixed Create new record or relationship record, and append the record into _rows list.
createReadQuery ( )
delete ( )
each ( callable $cb )
fetch ( ) : OperationResult Build sql and Fetch from current query, make a query to database.
fetchRow ( )
filter ( callable $cb )
first ( )
free ( ) Free cached row data and result handle, But still keep the same query.
fromArray ( array $list ) Create a collection object from an data array.
getAlias ( )
getCurrentReadQuery ( )
getExplicitColumnSelect ( BaseDriver $driver ) xxx: this might be used in other join statements.
getIterator ( )
getLastSql ( )
getQueryDriver ( $dsId ) Because it's used in BaseModel class too
getReadQueryDriver ( )
getResult ( )
getRows ( )
getSchema ( )
getSelected ( )
getSql ( )
getTable ( )
getVars ( )
getWriteQueryDriver ( )
items ( ) : BaseModel[] Get items.
join ( mixed $target, string $type = 'LEFT', string $alias = null, $relationId = null ) : QueryBuilder Override QueryBuilder->join method, to enable explict selection.
last ( )
limit ( integer $number ) Query Limit for QueryBuilder.
loadQuery ( string $sql, array $args = [], string $dsId = null ) Load Collection from a SQL query statement.
newModel ( ) : object Create model object.
offset ( integer $number ) Query offset for QueryBuilder.
offsetExists ( $name )
offsetGet ( $name )
offsetSet ( $name, $value ) array access interface
offsetUnset ( $name )
page ( integer $page, integer $pageSize = 20 ) A Short helper method for using limit and offset of QueryBuilder.
pager ( $page = 1, $pageSize = 10 ) : LazyRecord\CollectionPager Get selected items and wrap it into a CollectionPager object.
prepareHandle ( $force = false ) prepare data handle, call fetch method to read data from database, and catch the handle.
queryCount ( ) : integer Clone current read query and apply select to count(*) So that we can use the same conditions to query item count.
reset ( ) Free resources and reset query,arguments and data.
select ( $sels )
selectAll ( )
setAlias ( $alias )
setExplictSelect ( $boolean = true )
setPostCreate ( callable $cb )
setPreferredTable ( $tableName )
setPresetVars ( array $vars )
setRecords ( array $records ) Set record objects.
size ( ) : integer Get current selected item size by using php function count.
splice ( $pos, $count = null )
sql ( )
toArray ( )
toInflatedArray ( )
toJson ( )
toLabelValuePairs ( )
toPairs ( $key, $valueKey )
toSql ( ) Convert query to plain sql.
toXml ( )
toYaml ( )
update ( array $data ) Update collection.
where ( array $args = null ) Override QueryBuilder->where method, to enable explict selection.

Защищенные методы

Метод Описание
readRows ( ) : model_class[] Read rows from database handle.

Описание методов

__call() публичный метод

Dispatch undefined methods to SelectQuery object, To achieve mixin-like feature.
public __call ( $m, $a )

__clone() публичный метод

When cloning collection object, The resources will be free, and the query builder will be cloned.
public __clone ( )

__construct() публичный метод

public __construct ( )

__toString() публичный метод

public __toString ( )

add() публичный метод

public add ( BaseModel $record )
$record BaseModel

asPairs() публичный метод

Return pair array by columns.
public asPairs ( string $key, string $valueKey )
$key string
$valueKey string

count() публичный метод

This method implements the Countable interface.
public count ( )

create() публичный метод

Create new record or relationship record, and append the record into _rows list.
public create ( array $args ) : mixed
$args array Arguments for creating record
Результат mixed record object

createReadQuery() публичный метод

public createReadQuery ( )

delete() публичный метод

public delete ( )

each() публичный метод

public each ( callable $cb )
$cb callable

fetch() публичный метод

Build sql and Fetch from current query, make a query to database.
public fetch ( ) : OperationResult
Результат OperationResult

fetchRow() публичный метод

public fetchRow ( )

filter() публичный метод

public filter ( callable $cb )
$cb callable

first() публичный метод

public first ( )

free() публичный метод

Free cached row data and result handle, But still keep the same query.
public free ( )

fromArray() публичный статический метод

Create a collection object from an data array.
public static fromArray ( array $list )
$list array

getAlias() публичный метод

public getAlias ( )

getCurrentReadQuery() публичный метод

public getCurrentReadQuery ( )

getExplicitColumnSelect() публичный метод

xxx: this might be used in other join statements.
public getExplicitColumnSelect ( BaseDriver $driver )
$driver SQLBuilder\Driver\BaseDriver

getIterator() публичный метод

public getIterator ( )

getLastSql() публичный метод

public getLastSql ( )

getQueryDriver() публичный метод

Because it's used in BaseModel class too
public getQueryDriver ( $dsId )

getReadQueryDriver() публичный метод

public getReadQueryDriver ( )

getResult() публичный метод

public getResult ( )

getRows() публичный метод

public getRows ( )

getSchema() публичный метод

public getSchema ( )

getSelected() публичный метод

public getSelected ( )

getSql() публичный метод

public getSql ( )

getTable() публичный метод

public getTable ( )

getVars() публичный метод

public getVars ( )

getWriteQueryDriver() публичный метод

public getWriteQueryDriver ( )

items() публичный метод

Get items.
public items ( ) : BaseModel[]
Результат BaseModel[]

join() публичный метод

For model/collection objects, we should convert it to table name Usage: $collection->join( new Author, 'LEFT', 'a' ); // left join with alias 'a' $collection->join('authors'); // left join without alias $collection->join( new Author, 'LEFT' , 'a' ) ->on('m.author_id', array('a.id') ); // LEFT JOIN authors table on m.author_id = a.id $collection->join('authors','RIGHT','a'); // right join with alias 'a'
public join ( mixed $target, string $type = 'LEFT', string $alias = null, $relationId = null ) : QueryBuilder
$target mixed (Model object or table name)
$type string Join Type (default 'LEFT')
$alias string Alias
Результат QueryBuilder

last() публичный метод

public last ( )

limit() публичный метод

Query Limit for QueryBuilder.
public limit ( integer $number )
$number integer

loadQuery() публичный метод

Load Collection from a SQL query statement.
public loadQuery ( string $sql, array $args = [], string $dsId = null )
$sql string
$args array
$dsId string

newModel() публичный метод

Create model object.
public newModel ( ) : object
Результат object BaseModel

offset() публичный метод

Query offset for QueryBuilder.
public offset ( integer $number )
$number integer

offsetExists() публичный метод

public offsetExists ( $name )

offsetGet() публичный метод

public offsetGet ( $name )

offsetSet() публичный метод

array access interface
public offsetSet ( $name, $value )

offsetUnset() публичный метод

public offsetUnset ( $name )

page() публичный метод

A Short helper method for using limit and offset of QueryBuilder.
public page ( integer $page, integer $pageSize = 20 )
$page integer
$pageSize integer

pager() публичный метод

CollectionPager is a simple data pager, do not depends on database.
public pager ( $page = 1, $pageSize = 10 ) : LazyRecord\CollectionPager
Результат LazyRecord\CollectionPager

prepareHandle() публичный метод

Which calls doFetch() to do a query operation.
public prepareHandle ( $force = false )

queryCount() публичный метод

Clone current read query and apply select to count(*) So that we can use the same conditions to query item count.
public queryCount ( ) : integer
Результат integer

readRows() защищенный метод

Read rows from database handle.
protected readRows ( ) : model_class[]
Результат model_class[]

reset() публичный метод

Free resources and reset query,arguments and data.
public reset ( )

select() публичный метод

public select ( $sels )

selectAll() публичный метод

public selectAll ( )

setAlias() публичный метод

public setAlias ( $alias )

setExplictSelect() публичный метод

public setExplictSelect ( $boolean = true )

setPostCreate() публичный метод

public setPostCreate ( callable $cb )
$cb callable

setPreferredTable() публичный метод

public setPreferredTable ( $tableName )

setPresetVars() публичный метод

public setPresetVars ( array $vars )
$vars array

setRecords() публичный метод

Set record objects.
public setRecords ( array $records )
$records array

size() публичный метод

Get current selected item size by using php function count.
public size ( ) : integer
Результат integer size

splice() публичный метод

public splice ( $pos, $count = null )

sql() публичный метод

public sql ( )

toArray() публичный метод

public toArray ( )

toInflatedArray() публичный метод

public toInflatedArray ( )

toJson() публичный метод

public toJson ( )

toLabelValuePairs() публичный метод

public toLabelValuePairs ( )

toPairs() публичный метод

public toPairs ( $key, $valueKey )

toSql() публичный метод

Convert query to plain sql.
public toSql ( )

toXml() публичный метод

public toXml ( )

toYaml() публичный метод

public toYaml ( )

update() публичный метод

FIXME
public update ( array $data )
$data array

where() публичный метод

Override QueryBuilder->where method, to enable explict selection.
public where ( array $args = null )
$args array

Описание свойств

$_alias защищенное свойство

protected $_alias

$_lastSql защищенное свойство

protected $_lastSql

$_postCreate защищенное свойство

postCreate hook.
protected $_postCreate

$_presetVars защищенное свойство

preset vars for creating.
protected $_presetVars

$_readQuery публичное свойство

public $_readQuery

$_result защищенное свойство

operation result object.
protected $_result

$_rows защищенное свойство

handle data for items.
protected array $_rows
Результат array

$_schema защищенное свойство

protected $_schema

$_vars защищенное свойство

protected $_vars

$defaultOrdering защищенное свойство

$this->defaultOrdering = array( array( 'id', 'desc' ), array( 'name', 'desc' ), );.
protected $defaultOrdering

$explictSelect защищенное свойство

protected $explictSelect

$handle защищенное свойство

handle
protected $handle

$preferredTable защищенное свойство

protected $preferredTable

$selected публичное свойство

public $selected

$yamlExtension публичное статическое свойство

public static $yamlExtension