API Documentação da API
Lançado Adianti Framework 8.0!
Clique aqui para saber mais
Pacote Dominando o Adianti Framework
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

TRecord
in package
implements IteratorAggregate

AbstractYes

Base class for Active Records

Tags
version
8.0
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

Interfaces

IteratorAggregate

Properties

$attributes  : mixed
$data  : mixed
$readers  : mixed
$trashed  : mixed
$vdata  : mixed
$writers  : mixed

Methods

__callStatic()  : mixed
Executed whenever an unknown method is executed
__clone()  : mixed
Executed when the programmer clones an Active Record In this case, we have to clear the ID, to generate a new one
__construct()  : mixed
Class Constructor Instantiates the Active Record
__get()  : The
Executed whenever a property is accessed
__isset()  : mixed
Returns if a property is assigned
__set()  : mixed
Executed whenever a property is assigned
__unset()  : mixed
Unset a property
addAttribute()  : mixed
Register an persisted attribute
all()  : mixed
Returns all objects
belongsToMany()  : mixed
Load aggregated objects. Shortcut to loadAggregate
checkDependencies()  : mixed
Check active record dependencies
count()  : mixed
Creates a Repository with filter
countObjects()  : An
Method countObjects
create()  : mixed
Create a new TRecord and returns the instance
delete()  : mixed
Delete an Active Record object from the database
deleteComposite()  : mixed
Delete composite objects (parts in composition relationship)
evaluate()  : mixed
Evaluate variables inside brackets
exists()  : mixed
Tests if an ID exists
filterMany()  : mixed
Create a criteria to load composite objects
find()  : The
Find a Active Record and returns it
findAggregationFor()  : mixed
Returns the aggregation informatation for some class
findAssociationFor()  : mixed
Returns the association informatation for some class
findCompositionFor()  : mixed
Returns the composition informatation for some class
first()  : mixed
Returns the first object
firstOrCreate()  : mixed
First record or persist a new one
firstOrNew()  : mixed
First record or a new one
fromArray()  : mixed
Fill the Active Record properties from an indexed array
getAttributeList()  : mixed
Get attribute list
getAttributes()  : mixed
Return the persisted attributes
getByUserSessionIdentificator()  : A
Returns the information related to the logged user
getCacheControl()  : mixed
Returns the cache control
getCreatedAtColumn()  : A
Returns the name of the created at column
getCreatedByColumn()  : A
Returns the the name of the created at column
getDeletedAtColumn()  : A
Returns the name of the deleted at column
getDeletedByColumn()  : A
Returns the the name of the deleted at column
getEntity()  : A
Returns the name of database entity
getFirstID()  : An
Returns the FIRST Object ID from database
getIndexedArray()  : mixed
Creates an indexed array
getIterator()  : Traversable
Returns iterator
getLastID()  : An
Returns the LAST Object ID from database
getObjects()  : An
Method getObjects
getPrefilters()  : A
Returns the prefilters
getPrimaryKey()  : A
Returns the name of the primary key for that Active Record
getPrimaryKeyValue()  : The
Returns the primary key value for that Active Record
getUpdatedAtColumn()  : A
Returns the name of the updated at column
getUpdatedByColumn()  : A
Returns the the name of the updated at column
getVirtualData()  : mixed
Return virtual data (non-persistant properties)
groupBy()  : mixed
Creates a Repository with group
hasMany()  : mixed
Load composite objects. Shortcut for loadComposite
last()  : mixed
Returns the last object
load()  : The
Load an Active Record Object from the database
loadAggregate()  : mixed
Load aggregated objects (parts in aggregation relationship)
loadAggregatedClass()  : mixed
Load aggregated objects (parts in aggregation relationship)
loadAggregateIds()  : mixed
Load aggregated objects (parts in aggregation relationship)
loadComposite()  : mixed
Load composite objects (parts in composition relationship)
loadTrashed()  : mixed
Load trashed records
mergeObject()  : mixed
Fill the Active Record properties from another Active Record
orderBy()  : mixed
Creates an ordered repository
orWhere()  : mixed
Creates a Repository with OR filter
reload()  : mixed
ReLoad an Active Record Object from the database
render()  : mixed
Render variables inside brackets
restore()  : mixed
Restore soft deleted object
runReaders()  : mixed
Iterate readers to fill attributes
save()  : mixed
Save the object
saveAggregate()  : mixed
Save aggregated objects (parts in aggregation relationship)
saveComposite()  : mixed
Save composite objects (parts in composition relationship)
select()  : mixed
Creates a Repository with filter
set()  : mixed
Updates a Repository with filter
skip()  : mixed
Creates a Repository with offset
store()  : The
Store the objects into the database
take()  : mixed
Creates a Repository with limit
toArray()  : An
Return the Active Record properties as an indexed array
toJson()  : A
Return the Active Record properties as a json string
where()  : mixed
Creates a Repository with filter
withTrashed()  : mixed
getSequenceName()  : A
Returns the name of the sequence for primary key
runWriters()  : mixed
Iterate writers to fill dataset
underscoreFromCamelCase()  : mixed

Properties

$attributes

protected mixed $attributes

Methods

__callStatic()

Executed whenever an unknown method is executed

public static __callStatic(mixed $method, mixed $parameters) : mixed
Parameters
$method : mixed

Method name

$parameters : mixed

__clone()

Executed when the programmer clones an Active Record In this case, we have to clear the ID, to generate a new one

public __clone() : mixed

__construct()

Class Constructor Instantiates the Active Record

public __construct([mixed $id = NULL ][, mixed $callObjectLoad = TRUE ]) : mixed
Parameters
$id : mixed = NULL
$callObjectLoad : mixed = TRUE

__get()

Executed whenever a property is accessed

public __get(mixed $property) : The
Parameters
$property : mixed

Name of the object property

Return values
The

value of the property

__isset()

Returns if a property is assigned

public __isset(mixed $property) : mixed
Parameters
$property : mixed

Name of the object property

__set()

Executed whenever a property is assigned

public __set(mixed $property, mixed $value) : mixed
Parameters
$property : mixed

Name of the object property

$value : mixed

Value of the property

__unset()

Unset a property

public __unset(mixed $property) : mixed
Parameters
$property : mixed

Name of the object property

addAttribute()

Register an persisted attribute

public addAttribute(mixed $attribute[, mixed $writer = NULL ][, mixed $reader = NULL ]) : mixed
Parameters
$attribute : mixed

Attribute name

$writer : mixed = NULL

String, session var or callable to write this attribute

$reader : mixed = NULL

String, session var or callable to read this attribute

all()

Returns all objects

public static all([mixed $indexed = false ][, mixed $withTrashed = FALSE ]) : mixed
Parameters
$indexed : mixed = false
$withTrashed : mixed = FALSE

belongsToMany()

Load aggregated objects. Shortcut to loadAggregate

public belongsToMany(mixed $aggregate_class[, mixed $join_class = NULL ][, mixed $foreign_key_parent = NULL ][, mixed $foreign_key_child = NULL ]) : mixed
Parameters
$aggregate_class : mixed

Active Record Class for aggregated objects

$join_class : mixed = NULL

Active Record Join Class (Parent / Aggregated)

$foreign_key_parent : mixed = NULL

Foreign key in Join Class to parent object

$foreign_key_child : mixed = NULL

Foreign key in Join Class to child object

Tags
returns

Array of Active Records

checkDependencies()

Check active record dependencies

public checkDependencies(mixed $class, mixed $foreign_key[, mixed $id = null ][, mixed $label = null ]) : mixed
Parameters
$class : mixed
$foreign_key : mixed
$id : mixed = null
$label : mixed = null

count()

Creates a Repository with filter

public static count() : mixed
Tags
returns

the TRepository object with a filter

countObjects()

Method countObjects

public static countObjects([mixed $criteria = NULL ][, mixed $withTrashed = FALSE ]) : An
Parameters
$criteria : mixed = NULL

Optional criteria

$withTrashed : mixed = FALSE
Return values
An

array containing the Active Records

create()

Create a new TRecord and returns the instance

public static create(mixed $data) : mixed
Parameters
$data : mixed

indexed array

delete()

Delete an Active Record object from the database

public delete([mixed $id = NULL ]) : mixed
Parameters
$id : mixed = NULL
Tags
exception

Exception if there's no active transaction opened

deleteComposite()

Delete composite objects (parts in composition relationship)

public deleteComposite(mixed $composite_class, mixed $foreign_key, mixed $id[, mixed $callObjectLoad = FALSE ]) : mixed
Parameters
$composite_class : mixed

Active Record Class for composite objects

$foreign_key : mixed

Foreign key in composite objects

$id : mixed

Primary key of parent object

$callObjectLoad : mixed = FALSE

evaluate()

Evaluate variables inside brackets

public evaluate(mixed $pattern) : mixed
Parameters
$pattern : mixed

exists()

Tests if an ID exists

public exists(mixed $id) : mixed
Parameters
$id : mixed

The object ID

Tags
exception

Exception if there's no active transaction opened

filterMany()

Create a criteria to load composite objects

public filterMany(mixed $composite_class[, mixed $foreign_key = NULL ][, mixed $primary_key = NULL ][, mixed $order = NULL ]) : mixed
Parameters
$composite_class : mixed

Active Record Class for composite objects

$foreign_key : mixed = NULL

Foreign key in composite objects

$primary_key : mixed = NULL

Primary key of parent object

$order : mixed = NULL
Tags
returns

TRepository instance

find()

Find a Active Record and returns it

public static find(mixed $id[, mixed $withTrashed = FALSE ]) : The
Parameters
$id : mixed
$withTrashed : mixed = FALSE
Return values
The

Active Record itself or NULL when not found

findAggregationFor()

Returns the aggregation informatation for some class

public findAggregationFor(mixed $class) : mixed
Parameters
$class : mixed

Active Record Class name

findAssociationFor()

Returns the association informatation for some class

public findAssociationFor(mixed $class) : mixed
Parameters
$class : mixed

Active Record Class name

findCompositionFor()

Returns the composition informatation for some class

public findCompositionFor(mixed $class) : mixed
Parameters
$class : mixed

Active Record Class name

first()

Returns the first object

public static first([mixed $withTrashed = FALSE ]) : mixed
Parameters
$withTrashed : mixed = FALSE

firstOrCreate()

First record or persist a new one

public static firstOrCreate([mixed $filters = NULL ]) : mixed
Parameters
$filters : mixed = NULL

firstOrNew()

First record or a new one

public static firstOrNew([mixed $filters = NULL ]) : mixed
Parameters
$filters : mixed = NULL

fromArray()

Fill the Active Record properties from an indexed array

public fromArray(mixed $data[, mixed $check_attribute_list = true ]) : mixed
Parameters
$data : mixed

An indexed array containing the object properties

$check_attribute_list : mixed = true

getAttributeList()

Get attribute list

public getAttributeList() : mixed

getAttributes()

Return the persisted attributes

public getAttributes() : mixed

getByUserSessionIdentificator()

Returns the information related to the logged user

public getByUserSessionIdentificator() : A
Return values
A

String containing user login or id or custom code

getCacheControl()

Returns the cache control

public getCacheControl() : mixed

getCreatedAtColumn()

Returns the name of the created at column

public getCreatedAtColumn() : A
Return values
A

String containing the created at column

getCreatedByColumn()

Returns the the name of the created at column

public getCreatedByColumn() : A
Return values
A

String containing the created at column

getDeletedAtColumn()

Returns the name of the deleted at column

public static getDeletedAtColumn() : A
Return values
A

String containing the deleted at column

getDeletedByColumn()

Returns the the name of the deleted at column

public static getDeletedByColumn() : A
Return values
A

String containing the deleted at column

getEntity()

Returns the name of database entity

public getEntity() : A
Return values
A

String containing the name of the entity

getFirstID()

Returns the FIRST Object ID from database

public getFirstID() : An
Tags
exception

Exception if there's no active transaction opened

Return values
An

Integer containing the FIRST Object ID from database

getIndexedArray()

Creates an indexed array

public static getIndexedArray(mixed $indexColumn, mixed $valueColumn[, mixed $criteria = NULL ][, mixed $withTrashed = FALSE ]) : mixed
Parameters
$indexColumn : mixed
$valueColumn : mixed
$criteria : mixed = NULL
$withTrashed : mixed = FALSE
Tags
returns

the TRepository object with a filter

getIterator()

Returns iterator

public getIterator() : Traversable
Return values
Traversable

getLastID()

Returns the LAST Object ID from database

public getLastID() : An
Tags
exception

Exception if there's no active transaction opened

Return values
An

Integer containing the LAST Object ID from database

getObjects()

Method getObjects

public static getObjects([mixed $criteria = NULL ][, mixed $callObjectLoad = TRUE ][, mixed $withTrashed = FALSE ]) : An
Parameters
$criteria : mixed = NULL

Optional criteria

$callObjectLoad : mixed = TRUE

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

$withTrashed : mixed = FALSE
Return values
An

array containing the Active Records

getPrefilters()

Returns the prefilters

public static getPrefilters() : A
Return values
A

String containing the deleted at column

getPrimaryKey()

Returns the name of the primary key for that Active Record

public getPrimaryKey() : A
Return values
A

String containing the primary key name

getPrimaryKeyValue()

Returns the primary key value for that Active Record

public getPrimaryKeyValue() : The
Return values
The

primary key value

getUpdatedAtColumn()

Returns the name of the updated at column

public getUpdatedAtColumn() : A
Return values
A

String containing the updated at column

getUpdatedByColumn()

Returns the the name of the updated at column

public getUpdatedByColumn() : A
Return values
A

String containing the updated at column

getVirtualData()

Return virtual data (non-persistant properties)

public getVirtualData() : mixed

groupBy()

Creates a Repository with group

public static groupBy(mixed $group) : mixed
Parameters
$group : mixed
Tags
returns

the TRepository object with a group

hasMany()

Load composite objects. Shortcut for loadComposite

public hasMany(mixed $composite_class[, mixed $foreign_key = NULL ][, mixed $primary_key = NULL ][, mixed $order = NULL ]) : mixed
Parameters
$composite_class : mixed

Active Record Class for composite objects

$foreign_key : mixed = NULL

Foreign key in composite objects

$primary_key : mixed = NULL

Primary key of parent object

$order : mixed = NULL
Tags
returns

Array of Active Records

last()

Returns the last object

public static last([mixed $withTrashed = FALSE ]) : mixed
Parameters
$withTrashed : mixed = FALSE

load()

Load an Active Record Object from the database

public load(mixed $id) : The
Parameters
$id : mixed

The object ID

Tags
exception

Exception if there's no active transaction opened

Return values
The

Active Record Object

loadAggregate()

Load aggregated objects (parts in aggregation relationship)

public loadAggregate(mixed $aggregate_class, mixed $join_class, mixed $foreign_key_parent, mixed $foreign_key_child[, mixed $id = NULL ]) : mixed
Parameters
$aggregate_class : mixed

Active Record Class for aggregated objects

$join_class : mixed

Active Record Join Class (Parent / Aggregated)

$foreign_key_parent : mixed

Foreign key in Join Class to parent object

$foreign_key_child : mixed

Foreign key in Join Class to child object

$id : mixed = NULL

Primary key of parent object

Tags
returns

Array of Active Records

loadAggregatedClass()

Load aggregated objects (parts in aggregation relationship)

public loadAggregatedClass(mixed $aggregate_class) : mixed
Parameters
$aggregate_class : mixed

Active Record Class for aggregated objects

Tags
returns

Array of Active Records

loadAggregateIds()

Load aggregated objects (parts in aggregation relationship)

public loadAggregateIds(mixed $aggregate_class, mixed $join_class, mixed $foreign_key_parent, mixed $foreign_key_child[, mixed $id = NULL ]) : mixed
Parameters
$aggregate_class : mixed

Active Record Class for aggregated objects

$join_class : mixed

Active Record Join Class (Parent / Aggregated)

$foreign_key_parent : mixed

Foreign key in Join Class to parent object

$foreign_key_child : mixed

Foreign key in Join Class to child object

$id : mixed = NULL

Primary key of parent object

Tags
returns

Array of Active Records'Ids

loadComposite()

Load composite objects (parts in composition relationship)

public loadComposite(mixed $composite_class, mixed $foreign_key[, mixed $id = NULL ][, mixed $order = NULL ]) : mixed
Parameters
$composite_class : mixed

Active Record Class for composite objects

$foreign_key : mixed

Foreign key in composite objects

$id : mixed = NULL

Primary key of parent object

$order : mixed = NULL
Tags
returns

Array of Active Records

loadTrashed()

Load trashed records

public loadTrashed(mixed $id) : mixed
Parameters
$id : mixed

mergeObject()

Fill the Active Record properties from another Active Record

public mergeObject(mixed $object) : mixed
Parameters
$object : mixed

An Active Record

orderBy()

Creates an ordered repository

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

= Order column

$direction : mixed = 'asc'

= Order direction (asc, desc)

Tags
returns

the ordered TRepository object

orWhere()

Creates a Repository with OR filter

public static orWhere(mixed $variable, mixed $operator, mixed $value) : mixed
Parameters
$variable : mixed
$operator : mixed
$value : mixed
Tags
returns

the TRepository object with an OR filter

reload()

ReLoad an Active Record Object from the database

public reload() : mixed

render()

Render variables inside brackets

public render(mixed $pattern[, mixed $cast = null ]) : mixed
Parameters
$pattern : mixed
$cast : mixed = null

restore()

Restore soft deleted object

public restore() : mixed

runReaders()

Iterate readers to fill attributes

public runReaders() : mixed

save()

Save the object

public save() : mixed

saveAggregate()

Save aggregated objects (parts in aggregation relationship)

public saveAggregate(mixed $join_class, mixed $foreign_key_parent, mixed $foreign_key_child, mixed $id, mixed $objects) : mixed
Parameters
$join_class : mixed

Active Record Join Class (Parent / Aggregated)

$foreign_key_parent : mixed

Foreign key in Join Class to parent object

$foreign_key_child : mixed

Foreign key in Join Class to child object

$id : mixed

Primary key of parent object

$objects : mixed

Array of Active Records to be saved

saveComposite()

Save composite objects (parts in composition relationship)

public saveComposite(mixed $composite_class, mixed $foreign_key, mixed $id, mixed $objects[, mixed $callObjectLoad = FALSE ]) : mixed
Parameters
$composite_class : mixed

Active Record Class for composite objects

$foreign_key : mixed

Foreign key in composite objects

$id : mixed

Primary key of parent object

$objects : mixed

Array of Active Records to be saved

$callObjectLoad : mixed = FALSE

select()

Creates a Repository with filter

public static select() : mixed
Tags
returns

the TRepository object with a filter

set()

Updates a Repository with filter

public static set(mixed $column, mixed $value) : mixed
Parameters
$column : mixed
$value : mixed
Tags
returns

the TRepository object with a filter

skip()

Creates a Repository with offset

public static skip(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
returns

the TRepository object

store()

Store the objects into the database

public store() : The
Tags
exception

Exception if there's no active transaction opened

Return values
The

number of affected rows

take()

Creates a Repository with limit

public static take(mixed $limit) : mixed
Parameters
$limit : mixed
Tags
returns

the TRepository object

toArray()

Return the Active Record properties as an indexed array

public toArray([mixed $filter_attributes = null ]) : An
Parameters
$filter_attributes : mixed = null

Array of attributes to be returned.

Return values
An

indexed array containing the object properties

toJson()

Return the Active Record properties as a json string

public toJson() : A
Return values
A

JSON String

where()

Creates a Repository with filter

public static where(mixed $variable, mixed $operator, mixed $value[, mixed $logicOperator = TExpression::AND_OPERATOR ]) : mixed
Parameters
$variable : mixed
$operator : mixed
$value : mixed
$logicOperator : mixed = TExpression::AND_OPERATOR
Tags
returns

the TRepository object with a filter

withTrashed()

public static withTrashed() : mixed

getSequenceName()

Returns the name of the sequence for primary key

private getSequenceName() : A
Return values
A

String containing the sequence name

runWriters()

Iterate writers to fill dataset

private runWriters(mixed $sql, mixed $data) : mixed
Parameters
$sql : mixed

TSqlUpdate or TSqlInsert instance

$data : mixed

dataset

underscoreFromCamelCase()

private underscoreFromCamelCase(mixed $string) : mixed
Parameters
$string : mixed

        
On this page

Search results