|
Class TDataGatewayCommand
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.
-
TComponent
-
TDataGatewayCommand
Methods summary
public
|
|
public
TDbTableInfo
|
|
public
TDbConnection
|
|
public
TDbCommandBuilder
|
|
public
integer
|
#
delete( TSqlCriteria $criteria )
Executes a delete command.
Executes a delete command.
Parameters
Returns
integer number of records affected.
|
public
integer
|
#
update( array $data, TSqlCriteria $criteria )
Updates the table with new data.
Updates the table with new data.
Parameters
- $data
array date for update.
- $criteria
TSqlCriteria
update conditions and parameters.
Returns
integer number of records affected.
|
public
integer
|
#
updateByPk( array $data, array $keys )
Parameters
- $data
array update for update
- $keys
array primary key-value name pairs.
Returns
integer number of records affected.
|
public
array
|
#
find( TSqlCriteria $criteria )
Find one record matching the critera.
Find one record matching the critera.
Parameters
Returns
array matching record.
|
public
TDbDataReader
|
#
findAll( TSqlCriteria $criteria )
Find one or more matching records.
Find one or more matching records.
Parameters
Returns
|
protected
TDbCommand.
|
#
getFindCommand( TSqlCriteria $criteria )
Build the find command from the criteria. Limit, Offset and Ordering are
applied if applicable.
Build the find command from the criteria. Limit, Offset and Ordering are
applied if applicable.
Parameters
Returns
TDbCommand.
|
public
array
|
#
findByPk( mixed $keys )
Parameters
- $keys
mixed primary key value, or composite key values as array.
Returns
array matching record.
|
public
TDbDataReader
|
#
findAllByPk( array $keys )
Parameters
- $keys
array multiple primary key values or composite value arrays
Returns
|
public
|
#
findAllByIndex( mixed $criteria, mixed $fields, mixed $values )
|
public
integer
|
#
deleteByPk( array $keys )
Parameters
- $keys
array multiple primary key values or composite value arrays
Returns
integer number of rows affected.
|
public
|
#
getIndexKeyCondition( mixed $table, mixed $fields, mixed $values )
|
protected
|
#
getCompositeKeyCondition( array $values )
Construct a "pk IN ('key1', 'key2', ...)" criteria.
Construct a "pk IN ('key1', 'key2', ...)" criteria.
Parameters
- $values
array values for IN predicate
|
protected
string
|
#
quoteTuple( TDbConnection $array )
Parameters
Returns
string quoted recursive tuple values, e.g. "('val1', 'val2')".
|
protected
array
|
#
getPrimaryKeyCondition( array $values )
Create the condition and parameters for find by primary.
Create the condition and parameters for find by primary.
Parameters
- $values
array primary key values
Returns
array tuple($where, $parameters)
|
public
TDbDataReader
|
#
findBySql( TSqlCriteria $criteria )
Find one matching records for arbituary SQL.
Find one matching records for arbituary SQL.
Parameters
Returns
|
public
TDbDataReader
|
#
findAllBySql( TSqlCriteria $criteria )
Find zero or more matching records for arbituary SQL.
Find zero or more matching records for arbituary SQL.
Parameters
Returns
|
protected
TDbCommand
|
#
getSqlCommand( TSqlCriteria $criteria )
Build sql command from the criteria. Limit, Offset and Ordering are applied
if applicable.
Build sql command from the criteria. Limit, Offset and Ordering are applied
if applicable.
Parameters
Returns
|
public
integer
|
#
count( TSqlCriteria $criteria )
Parameters
Returns
integer number of records.
|
public
mixed
|
#
insert( array $data )
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.
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.
Parameters
- $data
array new record data.
Returns
mixed last insert id if one column contains a serial or sequence, otherwise true if
command executes successfully and affected 1 or more rows.
|
public
mixed
|
#
getLastInsertID( )
Iterate through all the columns and returns the last insert id of the first
column that has a sequence or serial.
Iterate through all the columns and returns the last insert id of the first
column that has a sequence or serial.
Returns
mixed last insert id, null if none is found.
|
public
TActiveRecordCriteria
|
#
createCriteriaFromString( string $method, string $condition, array $args )
Parameters
- $method
string __call method name
- $condition
string criteria conditions
- $args
array method arguments
Returns
|
public
|
#
onCreateCommand( TDataGatewayCommand $command, TDataGatewayEventParameter $criteria )
Raised when a command is prepared and parameter binding is completed. The
parameter object is TDataGatewayEventParameter of which the TDataGatewayEventParameter::getCommand Command property can be inspected to
obtain the sql query to be executed.
Raised when a command is prepared and parameter binding is completed. The
parameter object is TDataGatewayEventParameter of which the TDataGatewayEventParameter::getCommand Command property can be inspected to
obtain the sql query to be executed.
Parameters
|
public
|
#
onExecuteCommand( TDataGatewayCommand $command, TDataGatewayResultEventParameter $result )
Raised when a command is executed and the result from the database was
returned. The parameter object is TDataGatewayResultEventParameter of which the
TDataGatewayEventParameter::getResult Result property contains the data
return from the database. The data returned can be changed by setting the TDataGatewayEventParameter::setResult Result property.
Raised when a command is executed and the result from the database was
returned. The parameter object is TDataGatewayResultEventParameter of which the
TDataGatewayEventParameter::getResult Result property contains the data
return from the database. The data returned can be changed by setting the TDataGatewayEventParameter::setResult Result property.
Parameters
|
Methods inherited from TComponent
__call(),
__destruct(),
__get(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
addParsedObject(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
|