PHP Class Ouzo\Db\ModelQueryBuilder

Exibir arquivo Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
__clone ( )
__construct ( Model $model, Db $db = null, $alias = null )
_processResults ( $results )
copy ( )
count ( )
deleteAll ( ) Issues "delete from .
deleteEach ( ) Calls Model::delete method for each matching object
fetch ( ) : Model | array
fetchAll ( ) : Model[] | array[]
fetchIterator ( integer $batchSize = 500 ) : Iterator
getQuery ( )
groupBy ( $groupBy )
innerJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
join ( $relationSelector, null $aliases = null, string $type = 'LEFT', array $on = [] ) : ModelQueryBuilder
leftJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
limit ( $limit ) : ModelQueryBuilder
lockForUpdate ( ) : ModelQueryBuilder
offset ( $offset ) : ModelQueryBuilder
options ( array $options )
order ( $columns ) : ModelQueryBuilder
rightJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
select ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
selectDistinct ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
update ( array $attributes ) : integer Runs an update query against a set of models
using ( $relationSelector, null $aliases ) : ModelQueryBuilder
where ( string $where = '', array $values = [] ) : ModelQueryBuilder
with ( $relationSelector ) : ModelQueryBuilder

Private Methods

Method Description
_addRelationToFetch ( $relationToFetch )
addJoin ( ModelJoin $modelJoin )
aliasPrefixForSelect ( $alias )
createModelJoins ( $relationSelector, $aliases, $type, $on )
getModelAliasOrTable ( )
isAlreadyAddedToFetch ( RelationToFetch $relationToFetch )
isAlreadyJoined ( ModelJoin $modelJoin )
selectModelColumns ( Model $metaInstance, $alias )

Method Details

__clone() public method

public __clone ( )

__construct() public method

public __construct ( Model $model, Db $db = null, $alias = null )
$model Ouzo\Model
$db Ouzo\Db

_processResults() public method

public _processResults ( $results )

copy() public method

public copy ( )

count() public method

public count ( )

deleteAll() public method

.. where ..." sql command. Note that overridden Model::delete is not called.
public deleteAll ( )

deleteEach() public method

Calls Model::delete method for each matching object
public deleteEach ( )

fetch() public method

public fetch ( ) : Model | array
return Ouzo\Model | array

fetchAll() public method

public fetchAll ( ) : Model[] | array[]
return Ouzo\Model[] | array[]

fetchIterator() public method

public fetchIterator ( integer $batchSize = 500 ) : Iterator
$batchSize integer
return Iterator

getQuery() public method

public getQuery ( )

groupBy() public method

public groupBy ( $groupBy )

innerJoin() public method

public innerJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
$aliases null - alias of the first joined table or array of aliases for nested joins
$on array
return ModelQueryBuilder

join() public method

public join ( $relationSelector, null $aliases = null, string $type = 'LEFT', array $on = [] ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
$aliases null - alias of the first joined table or array of aliases for nested joins
$type string - join type, defaults to LEFT
$on array
return ModelQueryBuilder

leftJoin() public method

public leftJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
$aliases null - alias of the first joined table or array of aliases for nested joins
$on array
return ModelQueryBuilder

limit() public method

public limit ( $limit ) : ModelQueryBuilder
$limit
return ModelQueryBuilder

lockForUpdate() public method

public lockForUpdate ( ) : ModelQueryBuilder
return ModelQueryBuilder

offset() public method

public offset ( $offset ) : ModelQueryBuilder
$offset
return ModelQueryBuilder

options() public method

public options ( array $options )
$options array

order() public method

public order ( $columns ) : ModelQueryBuilder
$columns
return ModelQueryBuilder

rightJoin() public method

public rightJoin ( $relationSelector, null $aliases = null, array $on = [] ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
$aliases null - alias of the first joined table or array of aliases for nested joins
$on array
return ModelQueryBuilder

select() public method

public select ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
$columns
$type integer
return ModelQueryBuilder

selectDistinct() public method

public selectDistinct ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
$columns
$type integer
return ModelQueryBuilder

update() public method

Runs an update query against a set of models
public update ( array $attributes ) : integer
$attributes array
return integer

using() public method

public using ( $relationSelector, null $aliases ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
$aliases null - alias of the first joined table or array of aliases for nested joins
return ModelQueryBuilder

where() public method

public where ( string $where = '', array $values = [] ) : ModelQueryBuilder
$where string
$values array
return ModelQueryBuilder

with() public method

public with ( $relationSelector ) : ModelQueryBuilder
$relationSelector - Relation object, relation name or nested relations 'rel1->rel2'
return ModelQueryBuilder