Class TActiveRecordGateway
TActiveRecordGateway excutes the SQL command queries and returns the data record as arrays (for most finder methods).
| Constructor Summary |
| public |
Record gateway constructor.
|
| Method Summary |
|
int
|
Returns the number of records that match the given criteria.
|
|
int
|
delete
( TActiveRecord $record)
Delete the record.
|
|
int
|
Delete multiple records by criteria.
|
|
int
|
Delete multiple records using primary 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.
|
|
array
|
Return record data from sql query.
|
|
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.
|
|
void
|
findRecordsByIndex
( TActiveRecord $record, mixed $criteria, mixed $fields, mixed $values)
|
|
array
|
Returns records matching the list of given primary keys.
|
|
TDbDataReader
|
Return record data from sql query.
|
|
TDataGatewayCommand
|
|
|
protected
array
|
|
|
protected
TActiveRecordManager
|
|
|
protected
void
|
|
|
TDbTableInfo
|
Returns table information, trys the application cache first.
|
|
protected
string
|
Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.
|
|
TDbTableInfo
|
getTableInfo
( TDbConnection $connection, string $tableName)
Returns table information for table in the database connection.
|
|
protected
void
|
|
|
int
|
insert
( TActiveRecord $record)
Insert a new record.
|
|
void
|
Raised when a command is prepared and parameter binding is completed.
|
|
void
|
Raised when a command is executed and the result from the database was returned.
|
|
protected
void
|
Raise the corresponding command event, insert, update, delete or select.
|
|
int
|
update
( TActiveRecord $record)
Update the record.
|
|
protected
void
|
|
|
protected
void
|
Sets the last insert ID to the corresponding property of the record if available.
|
| Methods Inherited From TComponent |
|
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
|
| Constant Summary |
| string
|
TABLE_CONST |
Constant name for specifying optional table name in TActiveRecord.
|
| string
|
TABLE_METHOD |
Method name for returning optional table name in in TActiveRecord
|
| Constructor Details |
__construct
Record gateway constructor.
|
| Method Details |
countRecords
Returns the number of records that match the given criteria.
| Input |
| TActiveRecord | $record | active record finder instance. |
| TActiveRecordCriteria | $criteria | search criteria |
| Output |
|
int
| number of records. |
| Exception |
|
delete
| public int delete |
(TActiveRecord $record ) |
Delete the record.
| Input |
| TActiveRecord | $record | record to be deleted. |
| Output |
|
int
| number of rows affected. |
| Exception |
|
deleteRecordsByCriteria
Delete multiple records by criteria.
| Input |
| TActiveRecord | $record | active record finder instance. |
| TActiveRecordCriteria | $criteria | search criteria |
| Output |
|
int
| number of records. |
| Exception |
|
deleteRecordsByPk
| public int deleteRecordsByPk |
(TActiveRecord $record , mixed $keys ) |
Delete multiple records using primary keys.
| Input |
| TActiveRecord | $record | finder instance. |
| mixed | $keys | |
| Output |
|
int
| number of rows deleted. |
| Exception |
|
findRecordByPK
| public array findRecordByPK |
(TActiveRecord $record , array $keys ) |
Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.
| Input |
| TActiveRecord | $record | active record instance. |
| array | $keys | primary name value pairs |
| Output |
|
array
| record data |
| Exception |
|
findRecordBySql
Return record data from sql query.
| Input |
| TActiveRecord | $record | active record finder instance. |
| TActiveRecordCriteria | $criteria | sql query |
| Output |
|
array
| result. |
| Exception |
|
findRecordsByCriteria
| public mixed findRecordsByCriteria |
(TActiveRecord $record , TActiveRecordCriteria $criteria , boolean $iterator ) |
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.
| Input |
| TActiveRecord | $record | active record finder instance. |
| TActiveRecordCriteria | $criteria | search criteria. |
| boolean | $iterator | true to return multiple rows as iterator, false returns first row. |
| Output |
|
mixed
| matching data. |
| Exception |
|
findRecordsByIndex
| public void findRecordsByIndex |
(TActiveRecord $record , mixed $criteria , mixed $fields , mixed $values ) |
| Input |
| TActiveRecord | $record | |
| mixed | $criteria | |
| mixed | $fields | |
| mixed | $values | |
| Output |
| Exception |
|
findRecordsByPks
| public array findRecordsByPks |
(TActiveRecord $record , array $keys ) |
Returns records matching the list of given primary keys.
| Input |
| TActiveRecord | $record | active record instance. |
| array | $keys | list of primary name value pairs |
| Output |
|
array
| matching data. |
| Exception |
|
findRecordsBySql
Return record data from sql query.
|
getCommand
| Input |
| TActiveRecord | $record | |
| Output |
| Exception |
|
getInsertValues
| protected array getInsertValues |
(TActiveRecord $record ) |
| Input |
| TActiveRecord | $record | record |
| Output |
|
array
| insert values. |
| Exception |
|
getManager
|
getPrimaryKeyValues
| protected void getPrimaryKeyValues |
(TActiveRecord $record ) |
| Input |
| TActiveRecord | $record | |
| Output |
| Exception |
|
getRecordTableInfo
| public TDbTableInfo getRecordTableInfo |
(TActiveRecord $record ) |
Returns table information, trys the application cache first.
| Input |
| TActiveRecord | $record | |
| Output |
|
TDbTableInfo
| table information. |
| Exception |
|
getRecordTableName
| protected string getRecordTableName |
(TActiveRecord $record ) |
Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.
| Input |
| TActiveRecord | $record | active record instance |
| Output |
|
string
| table name for the given record class. |
| Exception |
|
getTableInfo
| public TDbTableInfo getTableInfo |
(TDbConnection $connection , string $tableName ) |
Returns table information for table in the database connection.
| Input |
| TDbConnection | $connection | database connection |
| string | $tableName | table name |
| Output |
|
TDbTableInfo
| table details. |
| Exception |
|
getUpdateValues
| protected void getUpdateValues |
(TActiveRecord $record ) |
| Input |
| TActiveRecord | $record | |
| Output |
| Exception |
|
insert
| public int insert |
(TActiveRecord $record ) |
Insert a new record.
| Input |
| TActiveRecord | $record | new record. |
| Output |
|
int
| number of rows affected. |
| Exception |
|
onCreateCommand
Raised when a command is prepared and parameter binding is completed.
The parameter object is TDataGatewayEventParameter of which the TDataGatewayEventParameter::getCommand 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.
|
onExecuteCommand
Raised when a command is executed and the result from the database was returned.
The parameter object is TDataGatewayResultEventParameter of which the TDataGatewayEventParameter::getResult property contains the data return from the database. The data returned can be changed by setting the TDataGatewayEventParameter::setResult property. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.
|
raiseCommandEvent
Raise the corresponding command event, insert, update, delete or select.
|
update
| public int update |
(TActiveRecord $record ) |
Update the record.
| Input |
| TActiveRecord | $record | dirty record. |
| Output |
|
int
| number of rows affected. |
| Exception |
|
updateAssociatedRecords
| protected void updateAssociatedRecords |
(TActiveRecord $record , mixed $updateBelongsTo ) |
| Input |
| TActiveRecord | $record | |
| mixed | $updateBelongsTo | |
| Output |
| Exception |
|
updatePostInsert
Sets the last insert ID to the corresponding property of the record if available.
|
| Constant Details |
TABLE_CONST
Constant name for specifying optional table name in TActiveRecord.
Type:
string
Value:
'TABLE'
|
TABLE_METHOD
Method name for returning optional table name in in TActiveRecord
Type:
string
Value:
'table'
|
|