PHP Класс 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 {@link 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 {@link OnExecuteCommand} event is raised after the command is executed and resulting data is set in the TDataGatewayResultEventParameter object's Result property.
С версии: 3.1
Наследование: extends Prado\TComponent
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( $builder )
count ( TSqlCriteria $criteria ) : integer
createCriteriaFromString ( $method, $condition, $args ) : TActiveRecordCriteria
delete ( $criteria ) : integer Executes a delete command.
deleteByPk ( $keys ) : integer
find ( $criteria ) : array Find one record matching the critera.
findAll ( TSqlCriteria $criteria ) : TDbDataReader Find one or more matching records.
findAllByIndex ( $criteria, $fields, $values )
findAllByPk ( $keys ) : TDbDataReader
findAllBySql ( TSqlCriteria $criteria ) : TDbDataReader Find zero or more matching records for arbituary SQL.
findByPk ( $keys ) : array
findBySql ( TSqlCriteria $criteria ) : TDbDataReader Find one matching records for arbituary SQL.
getBuilder ( ) : TDbCommandBuilder
getDbConnection ( ) : TDbConnection
getIndexKeyCondition ( $table, $fields, $values )
getLastInsertID ( ) : mixed Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
getTableInfo ( ) : TDbTableInfo
insert ( $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.
onCreateCommand ( $command, $criteria ) Raised when a command is prepared and parameter binding is completed.
onExecuteCommand ( $command, $result ) Raised when a command is executed and the result from the database was returned.
update ( $data, $criteria ) : integer Updates the table with new data.
updateByPk ( $data, $keys ) : integer

Защищенные методы

Метод Описание
extractMatchingConditions ( $method, $condition ) : array Calculates the AND/OR condition from dynamic method substrings using table meta data, allows for any AND-OR combinations.
getCompositeKeyCondition ( $values ) Construct a "pk IN ('key1', 'key2', .
getFindCommand ( TSqlCriteria $criteria ) : TDbCommand. Build the find command from the criteria. Limit, Offset and Ordering are applied if applicable.
getPrimaryKeyCondition ( $values ) : array Create the condition and parameters for find by primary.
getSqlCommand ( TSqlCriteria $criteria ) : TDbCommand Build sql command from the criteria. Limit, Offset and Ordering are applied if applicable.
quoteTuple ( $array ) : string

Описание методов

__construct() публичный Метод

public __construct ( $builder )

count() публичный Метод

public count ( TSqlCriteria $criteria ) : integer
$criteria TSqlCriteria
Результат integer number of records.

createCriteriaFromString() публичный Метод

public createCriteriaFromString ( $method, $condition, $args ) : TActiveRecordCriteria
Результат TActiveRecordCriteria criteria created from the method name and its arguments.

delete() публичный Метод

Executes a delete command.
public delete ( $criteria ) : integer
Результат integer number of records affected.

deleteByPk() публичный Метод

public deleteByPk ( $keys ) : integer
Результат integer number of rows affected.

extractMatchingConditions() защищенный Метод

Calculates the AND/OR condition from dynamic method substrings using table meta data, allows for any AND-OR combinations.
protected extractMatchingConditions ( $method, $condition ) : array
Результат array search condition substrings

find() публичный Метод

Find one record matching the critera.
public find ( $criteria ) : array
Результат array matching record.

findAll() публичный Метод

Find one or more matching records.
public findAll ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Результат TDbDataReader record reader.

findAllByIndex() публичный Метод

public findAllByIndex ( $criteria, $fields, $values )

findAllByPk() публичный Метод

public findAllByPk ( $keys ) : TDbDataReader
Результат TDbDataReader record reader.

findAllBySql() публичный Метод

Find zero or more matching records for arbituary SQL.
public findAllBySql ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Результат TDbDataReader record reader.

findByPk() публичный Метод

public findByPk ( $keys ) : array
Результат array matching record.

findBySql() публичный Метод

Find one matching records for arbituary SQL.
public findBySql ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Результат TDbDataReader record reader.

getBuilder() публичный Метод

public getBuilder ( ) : TDbCommandBuilder
Результат TDbCommandBuilder

getCompositeKeyCondition() защищенный Метод

..)" criteria.
protected getCompositeKeyCondition ( $values )

getDbConnection() публичный Метод

public getDbConnection ( ) : TDbConnection
Результат TDbConnection

getFindCommand() защищенный Метод

Build the find command from the criteria. Limit, Offset and Ordering are applied if applicable.
protected getFindCommand ( TSqlCriteria $criteria ) : TDbCommand.
$criteria TSqlCriteria
Результат TDbCommand.

getIndexKeyCondition() публичный Метод

public getIndexKeyCondition ( $table, $fields, $values )

getLastInsertID() публичный Метод

Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
public getLastInsertID ( ) : mixed
Результат mixed last insert id, null if none is found.

getPrimaryKeyCondition() защищенный Метод

Create the condition and parameters for find by primary.
protected getPrimaryKeyCondition ( $values ) : array
Результат array tuple($where, $parameters)

getSqlCommand() защищенный Метод

Build sql command from the criteria. Limit, Offset and Ordering are applied if applicable.
protected getSqlCommand ( TSqlCriteria $criteria ) : TDbCommand
$criteria TSqlCriteria
Результат TDbCommand command corresponding to the criteria.

getTableInfo() публичный Метод

public getTableInfo ( ) : TDbTableInfo
Результат TDbTableInfo

insert() публичный Метод

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 insert ( $data ) : mixed
Результат mixed last insert id if one column contains a serial or sequence, otherwise true if command executes successfully and affected 1 or more rows.

onCreateCommand() публичный Метод

The parameter object is TDataGatewayEventParameter of which the {@link TDataGatewayEventParameter::getCommand Command} property can be inspected to obtain the sql query to be executed.
public onCreateCommand ( $command, $criteria )

onExecuteCommand() публичный Метод

The parameter object is TDataGatewayResultEventParameter of which the {@link TDataGatewayEventParameter::getResult Result} property contains the data return from the database. The data returned can be changed by setting the {@link TDataGatewayEventParameter::setResult Result} property.
public onExecuteCommand ( $command, $result )

quoteTuple() защищенный Метод

protected quoteTuple ( $array ) : string
Результат string quoted recursive tuple values, e.g. "('val1', 'val2')".

update() публичный Метод

Updates the table with new data.
public update ( $data, $criteria ) : integer
Результат integer number of records affected.

updateByPk() публичный Метод

public updateByPk ( $data, $keys ) : integer
Результат integer number of records affected.