Class TDataGatewayCommand

Description

TDataGatewayCommand is command builder and executor class for TTableGateway and TActiveRecordGateway.

TDataGatewayCommand builds the TDbCommand for TTableGateway and TActiveRecordGateway commands such as find(), update(), insert(), etc, using the TDbCommandBuilder classes (database specific TDbCommandBuilder classes are used).

Once the command is built and the query parameters are binded, the OnCreateCommand event is raised. Event handlers for the OnCreateCommand event should not alter the Command property nor the Criteria property of the TDataGatewayEventParameter.

TDataGatewayCommand excutes the TDbCommands and returns the result obtained from the database (returned value depends on the method executed). The OnExecuteCommand event is raised after the command is executed and resulting data is set in the TDataGatewayResultEventParameter object's Result property.

Located in /Data/DataGateway/TDataGatewayCommand.php (line 37)

TComponent
   |
   --TDataGatewayCommand
Method Summary
TDataGatewayCommand __construct (TDbCommandBuilder $builder)
integer count (TSqlCriteria $criteria)
TActiveRecordCriteria createCriteriaFromString (string $method, string $condition, array $args)
integer delete (TSqlCriteria $criteria)
integer deleteByPk (array $keys)
array extractMatchingConditions (string $method, string $condition)
array find (TSqlCriteria $criteria)
void findAllByIndex ( $criteria,  $fields,  $values)
TDbDataReader findAllByPk (array $keys)
array findByPk (mixed $keys)
void getCompositeKeyCondition (array $values, string 1)
TDbCommand. getFindCommand (TSqlCriteria $criteria)
void getIndexKeyCondition ( $table,  $fields,  $values)
mixed getLastInsertID ()
array getPrimaryKeyCondition (array $values)
mixed insert (array $data)
string quoteTuple (TDbConnection $array, array 1)
integer update (array $data, TSqlCriteria $criteria)
integer updateByPk (array $data, array $keys)
Methods
Constructor __construct (line 44)
  • access: public
TDataGatewayCommand __construct (TDbCommandBuilder $builder)
count (line 332)
  • return: number of records.
  • access: public
integer count (TSqlCriteria $criteria)
createCriteriaFromString (line 382)
  • return: criteria created from the method name and its arguments.
  • access: public
TActiveRecordCriteria createCriteriaFromString (string $method, string $condition, array $args)
  • string $method: __call method name
  • string $condition: criteria conditions
  • array $args: method arguments
delete (line 78)

Executes a delete command.

  • return: number of records affected.
  • access: public
integer delete (TSqlCriteria $criteria)
deleteByPk (line 197)
  • return: number of rows affected.
  • access: public
integer deleteByPk (array $keys)
  • array $keys: multiple primary key values or composite value arrays
extractMatchingConditions (line 401)

Calculates the AND/OR condition from dynamic method substrings using table meta data, allows for any AND-OR combinations.

  • return: search condition substrings
  • access: protected
array extractMatchingConditions (string $method, string $condition)
  • string $method: dynamic method name
  • string $condition: dynamic method search criteria
find (line 120)

Find one record matching the critera.

  • return: matching record.
  • access: public
array find (TSqlCriteria $criteria)
findAll (line 131)

Find one or more matching records.

  • return: record reader.
  • access: public
TDbDataReader findAll (TSqlCriteria $criteria)
findAllByIndex (line 181)
  • access: public
void findAllByIndex ( $criteria,  $fields,  $values)
  • $criteria
  • $fields
  • $values
findAllByPk (line 173)
  • return: record reader.
  • access: public
TDbDataReader findAllByPk (array $keys)
  • array $keys: multiple primary key values or composite value arrays
findAllBySql (line 301)

Find zero or more matching records for arbituary SQL.

  • return: record reader.
  • access: public
TDbDataReader findAllBySql (TSqlCriteria $criteria)
findByPk (line 161)
  • return: matching record.
  • access: public
array findByPk (mixed $keys)
  • mixed $keys: primary key value, or composite key values as array.
findBySql (line 290)

Find one matching records for arbituary SQL.

  • return: record reader.
  • access: public
TDbDataReader findBySql (TSqlCriteria $criteria)
getBuilder (line 68)
  • access: public
TDbCommandBuilder getBuilder ()
getCompositeKeyCondition (line 222)

Construct a "pk IN ('key1', 'key2', ...)" criteria.

  • access: protected
void getCompositeKeyCondition (array $values, string 1)
  • string 1: SQL string for primary keys IN a list.
  • array $values: values for IN predicate
getDbConnection (line 60)
  • access: public
TDbConnection getDbConnection ()
getFindCommand (line 142)

Build the find command from the criteria. Limit, Offset and Ordering are applied if applicable.

  • access: protected
TDbCommand. getFindCommand (TSqlCriteria $criteria)
getIndexKeyCondition (line 206)
  • access: public
void getIndexKeyCondition ( $table,  $fields,  $values)
  • $table
  • $fields
  • $values
getLastInsertID (line 371)

Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.

  • return: last insert id, null if none is found.
  • access: public
mixed getLastInsertID ()
getPrimaryKeyCondition (line 265)

Create the condition and parameters for find by primary.

  • return: tuple($where, $parameters)
  • access: protected
array getPrimaryKeyCondition (array $values)
  • array $values: primary key values
getSqlCommand (line 312)

Build sql command from the criteria. Limit, Offset and Ordering are applied if applicable.

  • return: command corresponding to the criteria.
  • access: protected
TDbCommand getSqlCommand (TSqlCriteria $criteria)
getTableInfo (line 52)
  • access: public
TDbTableInfo getTableInfo ()
insert (line 353)

Inserts a new record into the table. Each array key must correspond to a column name in the table unless a null value is permitted.

  • return: last insert id if one column contains a serial or sequence, otherwise true if command executes successfully and affected 1 or more rows.
  • access: public
mixed insert (array $data)
  • array $data: new record data.
onCreateCommand (line 434)

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.

  • access: public
void onCreateCommand (TDataGatewayCommand $command, TDataGatewayEventParameter $criteria)
onExecuteCommand (line 448)

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.

  • access: public
void onExecuteCommand (TDataGatewayCommand $command, TDataGatewayResultEventParameter $result)
quoteTuple (line 251)
  • return: quoted recursive tuple values, e.g. "('val1', 'val2')".
  • access: protected
string quoteTuple (TDbConnection $array, array 1)
update (line 94)

Updates the table with new data.

  • return: number of records affected.
  • access: public
integer update (array $data, TSqlCriteria $criteria)
  • array $data: date for update.
  • TSqlCriteria $criteria: update conditions and parameters.
updateByPk (line 109)
  • return: number of records affected.
  • access: public
integer updateByPk (array $data, array $keys)
  • array $data: update for update
  • array $keys: primary key-value name pairs.

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::__call()
TComponent::__get()
TComponent::__set()
TComponent::__sleep()
TComponent::__wakeup()

Documentation generated on Mon, 25 Jun 2012 14:37:44 +0200 by phpDocumentor 1.4.3