Class TActiveRecordGateway

Description

TActiveRecordGateway excutes the SQL command queries and returns the data record as arrays (for most finder methods).

  • since: 3.1
  • version: $Id: TActiveRecordGateway.php 2323 2007-10-21 20:52:05Z xue $
  • author: Wei Zhuo <weizho[at]gmail[dot]com>

Located in /Data/ActiveRecord/TActiveRecordGateway.php (line 22)

TComponent
   |
   --TActiveRecordGateway
Class Constant Summary
 TABLE_CONST = 'TABLE'
Method Summary
TActiveRecordGateway __construct (TActiveRecordManager $manager)
int countRecords (TActiveRecord $record, TActiveRecordCriteria $criteria)
int delete (TActiveRecord $record)
int deleteRecordsByCriteria (TActiveRecord $record, TActiveRecordCriteria $criteria)
int deleteRecordsByPk (TActiveRecord $record, mixed $keys)
array findRecordByPK (TActiveRecord $record, array $keys)
array findRecordBySql (TActiveRecord $record, TActiveRecordCriteria $criteria)
mixed findRecordsByCriteria (TActiveRecord $record, TActiveRecordCriteria $criteria, [boolean $iterator = false])
void findRecordsByIndex (TActiveRecord $record, mixed $criteria, mixed $fields, mixed $values)
array findRecordsByPks (TActiveRecord $record, array $keys)
TDbDataReader findRecordsBySql (TActiveRecord $record, TActiveRecordCriteria $criteria)
TDataGatewayCommand getCommand (TActiveRecord $record)
array getInsertValues (TActiveRecord $record)
void getPrimaryKeyValues (TActiveRecord $record)
TDbTableInfo getRecordTableInfo (TActiveRecord $record)
string getRecordTableName (TActiveRecord $record)
TDbTableInfo getTableInfo (TDbConnection $connection, string $tableName)
void getUpdateValues (TActiveRecord $record)
int insert (TActiveRecord $record)
void raiseCommandEvent (string $event, TDbCommand $command, TActiveRecord $record, TActiveRecordCriteria $criteria)
int update (TActiveRecord $record)
void updateAssociatedRecords (TActiveRecord $record, [mixed $updateBelongsTo = false])
Methods
Constructor __construct (line 39)

Record gateway constructor.

  • access: public
TActiveRecordGateway __construct (TActiveRecordManager $manager)
countRecords (line 249)

Returns the number of records that match the given criteria.

  • return: number of records.
  • access: public
int countRecords (TActiveRecord $record, TActiveRecordCriteria $criteria)
delete (line 358)

Delete the record.

  • return: number of rows affected.
  • access: public
int delete (TActiveRecord $record)
deleteRecordsByCriteria (line 391)

Delete multiple records by criteria.

  • return: number of records.
  • access: public
int deleteRecordsByCriteria (TActiveRecord $record, TActiveRecordCriteria $criteria)
deleteRecordsByPk (line 380)

Delete multiple records using primary keys.

  • return: number of rows deleted.
  • access: public
int deleteRecordsByPk (TActiveRecord $record, mixed $keys)
findRecordByPK (line 184)

Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.

  • return: record data
  • access: public
array findRecordByPK (TActiveRecord $record, array $keys)
  • TActiveRecord $record: active record instance.
  • array $keys: primary name value pairs
findRecordBySql (line 222)

Return record data from sql query.

  • return: result.
  • access: public
array findRecordBySql (TActiveRecord $record, TActiveRecordCriteria $criteria)
findRecordsByCriteria (line 210)

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.

  • return: matching data.
  • access: public
mixed findRecordsByCriteria (TActiveRecord $record, TActiveRecordCriteria $criteria, [boolean $iterator = false])
  • TActiveRecord $record: active record finder instance.
  • TActiveRecordCriteria $criteria: search criteria.
  • boolean $iterator: true to return multiple rows as iterator, false returns first row.
findRecordsByIndex (line 238)
  • access: public
void findRecordsByIndex (TActiveRecord $record, mixed $criteria, mixed $fields, mixed $values)
findRecordsByPks (line 196)

Returns records matching the list of given primary keys.

  • return: matching data.
  • access: public
array findRecordsByPks (TActiveRecord $record, array $keys)
  • TActiveRecord $record: active record instance.
  • array $keys: list of primary name value pairs
findRecordsBySql (line 233)

Return record data from sql query.

  • return: result iterator.
  • access: public
TDbDataReader findRecordsBySql (TActiveRecord $record, TActiveRecordCriteria $criteria)
getCommand (line 122)
  • access: public
TDataGatewayCommand getCommand (TActiveRecord $record)
getInsertValues (line 288)
  • return: insert values.
  • access: protected
array getInsertValues (TActiveRecord $record)
getManager (line 47)
  • return: record manager.
  • access: protected
TActiveRecordManager getManager ()
getPrimaryKeyValues (line 363)
  • access: protected
void getPrimaryKeyValues (TActiveRecord $record)
getRecordTableInfo (line 78)

Returns table information, trys the application cache first.

  • return: table information.
  • access: public
TDbTableInfo getRecordTableInfo (TActiveRecord $record)
getRecordTableName (line 58)

Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.

  • return: table name for the given record class.
  • access: protected
string getRecordTableName (TActiveRecord $record)
getTableInfo (line 90)

Returns table information for table in the database connection.

  • return: table details.
  • access: public
TDbTableInfo getTableInfo (TDbConnection $connection, string $tableName)
  • TDbConnection $connection: database connection
  • string $tableName: table name
getUpdateValues (line 323)
  • access: protected
void getUpdateValues (TActiveRecord $record)
insert (line 259)

Insert a new record.

  • return: number of rows affected.
  • access: public
int insert (TActiveRecord $record)
onCreateCommand (line 152)

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.

  • access: public
void onCreateCommand (TDataGatewayCommand $sender, TDataGatewayEventParameter $param)
onExecuteCommand (line 170)

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.

  • access: public
void onExecuteCommand (TDataGatewayCommand $sender, TDataGatewayResultEventParameter $param)
raiseCommandEvent (line 403)

Raise the corresponding command event, insert, update, delete or select.

  • access: protected
void raiseCommandEvent (string $event, TDbCommand $command, TActiveRecord $record, TActiveRecordCriteria $criteria)
update (line 314)

Update the record.

  • return: number of rows affected.
  • access: public
int update (TActiveRecord $record)
updateAssociatedRecords (line 347)
  • access: protected
void updateAssociatedRecords (TActiveRecord $record, [mixed $updateBelongsTo = false])
updatePostInsert (line 273)

Sets the last insert ID to the corresponding property of the record if available.

  • access: protected
void updatePostInsert (TActiveRecord $record)

Inherited 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()
Class Constants
TABLE_CONST = 'TABLE' (line 33)

Constant name for specifying optional table name in TActiveRecord.

Documentation generated on Mon, 21 Apr 2008 11:29:41 -0400 by phpDocumentor 1.3.0RC4