PHP Class Prado\Data\ActiveRecord\TActiveRecordGateway

Since: 3.1
Inheritance: extends Prado\TComponent
Afficher le fichier Open project: pradosoft/prado

Méthodes publiques

Méthode Description
__construct ( TActiveRecordManager $manager ) Record gateway constructor.
countRecords ( TActiveRecord $record, $criteria ) : integer Returns the number of records that match the given criteria.
delete ( TActiveRecord $record ) : integer Delete the record.
deleteRecordsByCriteria ( TActiveRecord $record, $criteria ) : integer Delete multiple records by criteria.
deleteRecordsByPk ( TActiveRecord $record, $keys ) : integer Delete multiple records using primary keys.
findRecordByPK ( TActiveRecord $record, $keys ) : array Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.
findRecordBySql ( TActiveRecord $record, $criteria ) : array Return record data from sql query.
findRecordsByCriteria ( TActiveRecord $record, $criteria, $iterator = false ) : mixed Returns record data matching the given critera. If $iterator is true, it will return multiple rows as TDbDataReader otherwise it returns the first row data.
findRecordsByIndex ( TActiveRecord $record, $criteria, $fields, $values )
findRecordsByPks ( TActiveRecord $record, $keys ) : array Returns records matching the list of given primary keys.
findRecordsBySql ( TActiveRecord $record, $criteria ) : TDbDataReader Return record data from sql query.
getCommand ( TActiveRecord $record ) : TDataGatewayCommand
getRecordTableInfo ( TActiveRecord $record ) : TDbTableInfo Returns table information, trys the application cache first.
getTableInfo ( TDbConnection $connection, $tableName ) : TDbTableInfo Returns table information for table in the database connection.
insert ( TActiveRecord $record ) : integer Insert a new record.
onCreateCommand ( $sender, $param ) Raised when a command is prepared and parameter binding is completed.
onExecuteCommand ( $sender, $param ) Raised when a command is executed and the result from the database was returned.
update ( TActiveRecord $record ) : integer Update the record.

Méthodes protégées

Méthode Description
getInsertValues ( TActiveRecord $record ) : array
getManager ( ) : TActiveRecordManager
getPrimaryKeyValues ( TActiveRecord $record )
getRecordTableName ( TActiveRecord $record ) : string Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.
getUpdateValues ( TActiveRecord $record )
raiseCommandEvent ( $event, $command, $record, $criteria ) Raise the corresponding command event, insert, update, delete or select.
updateAssociatedRecords ( TActiveRecord $record, $updateBelongsTo = false )
updatePostInsert ( $record ) Sets the last insert ID to the corresponding property of the record if available.

Method Details

__construct() public méthode

Record gateway constructor.
public __construct ( TActiveRecordManager $manager )
$manager TActiveRecordManager

countRecords() public méthode

Returns the number of records that match the given criteria.
public countRecords ( TActiveRecord $record, $criteria ) : integer
$record TActiveRecord
Résultat integer number of records.

delete() public méthode

Delete the record.
public delete ( TActiveRecord $record ) : integer
$record TActiveRecord
Résultat integer number of rows affected.

deleteRecordsByCriteria() public méthode

Delete multiple records by criteria.
public deleteRecordsByCriteria ( TActiveRecord $record, $criteria ) : integer
$record TActiveRecord
Résultat integer number of records.

deleteRecordsByPk() public méthode

Delete multiple records using primary keys.
public deleteRecordsByPk ( TActiveRecord $record, $keys ) : integer
$record TActiveRecord
Résultat integer number of rows deleted.

findRecordByPK() public méthode

Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.
public findRecordByPK ( TActiveRecord $record, $keys ) : array
$record TActiveRecord
Résultat array record data

findRecordBySql() public méthode

Return record data from sql query.
public findRecordBySql ( TActiveRecord $record, $criteria ) : array
$record TActiveRecord
Résultat array result.

findRecordsByCriteria() public méthode

Returns record data matching the given critera. If $iterator is true, it will return multiple rows as TDbDataReader otherwise it returns the first row data.
public findRecordsByCriteria ( TActiveRecord $record, $criteria, $iterator = false ) : mixed
$record TActiveRecord
Résultat mixed matching data.

findRecordsByIndex() public méthode

public findRecordsByIndex ( TActiveRecord $record, $criteria, $fields, $values )
$record TActiveRecord

findRecordsByPks() public méthode

Returns records matching the list of given primary keys.
public findRecordsByPks ( TActiveRecord $record, $keys ) : array
$record TActiveRecord
Résultat array matching data.

findRecordsBySql() public méthode

Return record data from sql query.
public findRecordsBySql ( TActiveRecord $record, $criteria ) : TDbDataReader
$record TActiveRecord
Résultat TDbDataReader result iterator.

getCommand() public méthode

public getCommand ( TActiveRecord $record ) : TDataGatewayCommand
$record TActiveRecord
Résultat Prado\Data\DataGateway\TDataGatewayCommand

getInsertValues() protected méthode

protected getInsertValues ( TActiveRecord $record ) : array
$record TActiveRecord
Résultat array insert values.

getManager() protected méthode

protected getManager ( ) : TActiveRecordManager
Résultat TActiveRecordManager record manager.

getPrimaryKeyValues() protected méthode

protected getPrimaryKeyValues ( TActiveRecord $record )
$record TActiveRecord

getRecordTableInfo() public méthode

Returns table information, trys the application cache first.
public getRecordTableInfo ( TActiveRecord $record ) : TDbTableInfo
$record TActiveRecord
Résultat TDbTableInfo table information.

getRecordTableName() protected méthode

Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.
protected getRecordTableName ( TActiveRecord $record ) : string
$record TActiveRecord
Résultat string table name for the given record class.

getTableInfo() public méthode

Returns table information for table in the database connection.
public getTableInfo ( TDbConnection $connection, $tableName ) : TDbTableInfo
$connection Prado\Data\TDbConnection
Résultat TDbTableInfo table details.

getUpdateValues() protected méthode

protected getUpdateValues ( TActiveRecord $record )
$record TActiveRecord

insert() public méthode

Insert a new record.
public insert ( TActiveRecord $record ) : integer
$record TActiveRecord
Résultat integer number of rows affected.

onCreateCommand() public méthode

The parameter object is TDataGatewayEventParameter of which the {@link TDataGatewayEventParameter::getCommand Command} property can be inspected to obtain the sql query to be executed. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.
public onCreateCommand ( $sender, $param )

onExecuteCommand() public méthode

The parameter object is TDataGatewayResultEventParameter of which the {@link TDataGatewayEventParameter::getResult Result} property contains the data return from the database. The data returned can be changed by setting the {@link TDataGatewayEventParameter::setResult Result} property. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.
public onExecuteCommand ( $sender, $param )

raiseCommandEvent() protected méthode

Raise the corresponding command event, insert, update, delete or select.
protected raiseCommandEvent ( $event, $command, $record, $criteria )

update() public méthode

Update the record.
public update ( TActiveRecord $record ) : integer
$record TActiveRecord
Résultat integer number of rows affected.

updateAssociatedRecords() protected méthode

protected updateAssociatedRecords ( TActiveRecord $record, $updateBelongsTo = false )
$record TActiveRecord

updatePostInsert() protected méthode

Sets the last insert ID to the corresponding property of the record if available.
protected updatePostInsert ( $record )