API Documentação da API
Inscrições abertas para nosso Webinar anual Adianti Framework 2024!
Clique aqui para saber mais
Pacote Dominando o Adianti 7
Curso + Livro + Apps exemplo
Curso completo em Video Aulas (114 aulas).
Livro completo em PDF (463 páginas).
Códigos-fontes de Apps de exemplo.
API
API do Framework
Documentation

Documentation

TRepository
in package

Implements the Repository Pattern to deal with collections of Active Records

Tags
version
7.6
author

Pablo Dall'Oglio

copyright

Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)

license

https://adiantiframework.com.br/license

Table of Contents

Properties

$aggregates  : mixed
$class  : mixed
$colTransformers  : mixed
$columns  : mixed
$criteria  : mixed
$setValues  : mixed
$trashed  : mixed

Methods

__construct()  : mixed
Class Constructor
avgBy()  : An
Average aggregate
avgByAnd()  : self
Average aggregate and do another aggregate after
count()  : An
Return the amount of objects that satisfy a given criteria
countBy()  : An
Count aggregate
countByAnd()  : self
Count aggregate and do another aggregate after
countDistinctBy()  : An
Count distinct aggregate
delete()  : The
Delete a collection of Active Records from database
dump()  : mixed
Dump Criteria
filter()  : mixed
Returns filtered collection
first()  : mixed
Returns the first collection item
get()  : mixed
Alias for load()
getIndexedArray()  : mixed
Return a indexed array
groupBy()  : A
Define the group for criteria using fluent interfaces
last()  : mixed
Returns the last collection item
load()  : An
Load a collection of objects from database using a criteria
loadStatic()  : mixed
Load with no aggregates
maxBy()  : An
Max aggregate
maxByAnd()  : self
Max aggregate and do another aggregate after
minBy()  : An
Min aggregate
minByAnd()  : self
Min aggregate and do another aggregate after
orderBy()  : A
Define the ordering for criteria using fluent interfaces
orWhere()  : A
Add a run time OR criteria using fluent interfaces
select()  : mixed
Define columns list
set()  : A
Assign values to the database columns
setCriteria()  : mixed
Set criteria
skip()  : A
Define the OFFSET criteria using fluent interfaces
sumBy()  : An
Sum aggregate
sumByAnd()  : self
Sum aggregate and do another aggregate after
take()  : A
Define the LIMIT criteria using fluent interfaces
transform()  : mixed
Returns transformed collection
transformColumn()  : mixed
Set a transformation for a column
update()  : mixed
Update values in the repository
where()  : A
Add a run time criteria using fluent interfaces
withTrashed()  : mixed
Set withTrashed using fluent interfaces
aggregate()  : An
Aggregate column
getAttributeList()  : mixed
Get attribute list from entity
getEntity()  : A
Returns the name of database entity

Properties

Methods

__construct()

Class Constructor

public __construct( $class[, mixed $withTrashed = FALSE ]) : mixed
Parameters
$class :

= Active Record class name

$withTrashed : mixed = FALSE

avgBy()

Average aggregate

public avgBy( $column[,  $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

avgByAnd()

Average aggregate and do another aggregate after

public avgByAnd( $column[,  $alias = null ][, callable $transformation = null ]) : self
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
self

object

count()

Return the amount of objects that satisfy a given criteria

public count([ $criteria = NULL ]) : An
Parameters
$criteria : = NULL

An TCriteria object, specifiyng the filters

Return values
An

Integer containing the amount of objects that satisfy the criteria

countBy()

Count aggregate

public countBy( $column[,  $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

countByAnd()

Count aggregate and do another aggregate after

public countByAnd( $column[,  $alias = null ][, callable $transformation = null ]) : self
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
self

object

countDistinctBy()

Count distinct aggregate

public countDistinctBy( $column[, mixed $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : mixed = null
$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

delete()

Delete a collection of Active Records from database

public delete([ $criteria = NULL ][, mixed $callObjectLoad = FALSE ]) : The
Parameters
$criteria : = NULL

An TCriteria object, specifiyng the filters

$callObjectLoad : mixed = FALSE
Return values
The

affected rows

dump()

Dump Criteria

public dump([mixed $prepared = FALSE ]) : mixed
Parameters
$prepared : mixed = FALSE

filter()

Returns filtered collection

public filter(callable $callback[, mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$callback : callable
$callObjectLoad : mixed = TRUE

first()

Returns the first collection item

public first([mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$callObjectLoad : mixed = TRUE

get()

Alias for load()

public get([TCriteria $criteria = NULL ][, mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$criteria : TCriteria = NULL
$callObjectLoad : mixed = TRUE

getIndexedArray()

Return a indexed array

public getIndexedArray(mixed $indexColumn[, mixed $valueColumn = NULL ][, mixed $criteria = NULL ]) : mixed
Parameters
$indexColumn : mixed
$valueColumn : mixed = NULL
$criteria : mixed = NULL

groupBy()

Define the group for criteria using fluent interfaces

public groupBy( $group) : A
Parameters
$group :

Group column

Return values
A

TRepository object

last()

Returns the last collection item

public last([mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$callObjectLoad : mixed = TRUE

load()

Load a collection of objects from database using a criteria

public load([ $criteria = NULL ][,  $callObjectLoad = TRUE ]) : An
Parameters
$criteria : = NULL

An TCriteria object, specifiyng the filters

$callObjectLoad : = TRUE

If load() method from Active Records must be called to load object parts

Return values
An

array containing the Active Records

loadStatic()

Load with no aggregates

public loadStatic() : mixed

maxBy()

Max aggregate

public maxBy( $column[,  $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

maxByAnd()

Max aggregate and do another aggregate after

public maxByAnd( $column[,  $alias = null ][, callable $transformation = null ]) : self
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
self

object

minBy()

Min aggregate

public minBy( $column[,  $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

minByAnd()

Min aggregate and do another aggregate after

public minByAnd( $column[,  $alias = null ][, callable $transformation = null ]) : self
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
self

object

orderBy()

Define the ordering for criteria using fluent interfaces

public orderBy( $order[,  $direction = 'asc' ]) : A
Parameters
$order :

= Order column

$direction : = 'asc'

= Order direction (asc, desc)

Return values
A

TRepository object

orWhere()

Add a run time OR criteria using fluent interfaces

public orWhere( $variable,  $operator,  $value) : A
Parameters
$variable :

= variable

$operator :

= comparison operator (>,<,=)

$value :

= value to be compared

Return values
A

TRepository object

select()

Define columns list

public select(mixed $columns) : mixed
Parameters
$columns : mixed

set()

Assign values to the database columns

public set( $column,  $value) : A
Parameters
$column :

= column name

$value :

= column value

Return values
A

TRepository object

skip()

Define the OFFSET criteria using fluent interfaces

public skip( $offset) : A
Parameters
$offset :

= Offset

Return values
A

TRepository object

sumBy()

Sum aggregate

public sumBy( $column[,  $alias = null ][, callable $transformation = null ]) : An
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

sumByAnd()

Sum aggregate and do another aggregate after

public sumByAnd( $column[,  $alias = null ][, callable $transformation = null ]) : self
Parameters
$column :

Column to be aggregated

$alias : = null

Column alias

$transformation : callable = null
Return values
self

object

take()

Define the LIMIT criteria using fluent interfaces

public take( $limit) : A
Parameters
$limit :

= Limit

Return values
A

TRepository object

transform()

Returns transformed collection

public transform(callable $callback[, mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$callback : callable
$callObjectLoad : mixed = TRUE

transformColumn()

Set a transformation for a column

public transformColumn(mixed $alias, callable $callback) : mixed
Parameters
$alias : mixed
$callback : callable

update()

Update values in the repository

public update([mixed $setValues = NULL ][, TCriteria $criteria = NULL ]) : mixed
Parameters
$setValues : mixed = NULL
$criteria : TCriteria = NULL

where()

Add a run time criteria using fluent interfaces

public where( $variable,  $operator,  $value[,  $logicOperator = TExpression::AND_OPERATOR ]) : A
Parameters
$variable :

= variable

$operator :

= comparison operator (>,<,=)

$value :

= value to be compared

$logicOperator : = TExpression::AND_OPERATOR

= logical operator (TExpression::AND_OPERATOR, TExpression::OR_OPERATOR)

Return values
A

TRepository object

withTrashed()

Set withTrashed using fluent interfaces

public withTrashed() : mixed

aggregate()

Aggregate column

protected aggregate( $function, mixed $column[, mixed $alias = null ][, callable $transformation = null ]) : An
Parameters
$function :

Aggregate function (count, sum, min, max, avg)

$column : mixed
$alias : mixed = null
$transformation : callable = null
Return values
An

array of objects or the total value (if does not have group by)

getAttributeList()

Get attribute list from entity

protected getAttributeList() : mixed

getEntity()

Returns the name of database entity

protected getEntity() : A
Return values
A

String containing the name of the entity


        
On this page

Search results