Class \Prado\Data\DataGateway\TDataGatewayCommand
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.
Class hierarchy
Author: Wei Zhuo <weizho[at]gmail[dot]com>Since: 3.1
public
|
|
public
|
|
public
|
createCriteriaFromString(string $method, string $condition, array<string|int, mixed> $args) : TActiveRecordCriteria
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
findAllBySql(TSqlCriteria $criteria) : TDbDataReader
Find zero or more matching records for arbituary SQL.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
getLastInsertID() : mixed
Iterate through all the columns and returns the last insert id of the
first column that has a sequence or serial.
|
public
|
|
public
|
insert(array<string|int, mixed> $data) : mixed
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.
|
public
|
onCreateCommand(TDataGatewayCommand $command, mixed $criteria) : mixed
Raised when a command is prepared and parameter binding is completed.
The parameter object is TDataGatewayEventParameter of which the \Prado\Data\DataGateway\TDataGatewayEventParameter::getCommand property can be inspected to obtain the sql query to be executed. |
public
|
onExecuteCommand(TDataGatewayCommand $command, mixed $result) : mixed
Raised when a command is executed and the result from the database was returned.
The parameter object is TDataGatewayResultEventParameter of which the \Prado\Data\DataGateway\TDataGatewayEventParameter::getResult property contains the data return from the database. The data returned can be changed by setting the \Prado\Data\DataGateway\TDataGatewayEventParameter::setResult property. |
public
|
update(array<string|int, mixed> $data, TSqlCriteria $criteria) : int
Updates the table with new data.
|
public
|
|
protected
|
extractMatchingConditions(string $method, string $condition) : array<string|int, mixed>
Calculates the AND/OR condition from dynamic method substrings using
table meta data, allows for any AND-OR combinations.
|
protected
|
getCompositeKeyCondition(array<string|int, mixed> $values) : string
Construct a "pk IN ('key1', 'key2', ...)" criteria.
|
protected
|
getFindCommand(TSqlCriteria $criteria) : TDbCommand
Build the find command from the criteria. Limit, Offset and Ordering are applied if applicable.
|
protected
|
getPrimaryKeyCondition(array<string|int, mixed> $values) : array<string|int, mixed>
Create the condition and parameters for find by primary.
|
protected
|
getSqlCommand(TSqlCriteria $criteria) : TDbCommand
Build sql command from the criteria. Limit, Offset and Ordering are applied if applicable.
|
protected
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |