PHP 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 {@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.
Since: 3.1
Inheritance: extends Prado\TComponent
Afficher le fichier Open project: pradosoft/prado

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

public __construct ( $builder )

count() public méthode

public count ( TSqlCriteria $criteria ) : integer
$criteria TSqlCriteria
Résultat integer number of records.

createCriteriaFromString() public méthode

public createCriteriaFromString ( $method, $condition, $args ) : TActiveRecordCriteria
Résultat TActiveRecordCriteria criteria created from the method name and its arguments.

delete() public méthode

Executes a delete command.
public delete ( $criteria ) : integer
Résultat integer number of records affected.

deleteByPk() public méthode

public deleteByPk ( $keys ) : integer
Résultat integer number of rows affected.

extractMatchingConditions() protected méthode

Calculates the AND/OR condition from dynamic method substrings using table meta data, allows for any AND-OR combinations.
protected extractMatchingConditions ( $method, $condition ) : array
Résultat array search condition substrings

find() public méthode

Find one record matching the critera.
public find ( $criteria ) : array
Résultat array matching record.

findAll() public méthode

Find one or more matching records.
public findAll ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Résultat TDbDataReader record reader.

findAllByIndex() public méthode

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

findAllByPk() public méthode

public findAllByPk ( $keys ) : TDbDataReader
Résultat TDbDataReader record reader.

findAllBySql() public méthode

Find zero or more matching records for arbituary SQL.
public findAllBySql ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Résultat TDbDataReader record reader.

findByPk() public méthode

public findByPk ( $keys ) : array
Résultat array matching record.

findBySql() public méthode

Find one matching records for arbituary SQL.
public findBySql ( TSqlCriteria $criteria ) : TDbDataReader
$criteria TSqlCriteria
Résultat TDbDataReader record reader.

getBuilder() public méthode

public getBuilder ( ) : TDbCommandBuilder
Résultat TDbCommandBuilder

getCompositeKeyCondition() protected méthode

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

getDbConnection() public méthode

public getDbConnection ( ) : TDbConnection
Résultat TDbConnection

getFindCommand() protected méthode

Build the find command from the criteria. Limit, Offset and Ordering are applied if applicable.
protected getFindCommand ( TSqlCriteria $criteria ) : TDbCommand.
$criteria TSqlCriteria
Résultat TDbCommand.

getIndexKeyCondition() public méthode

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

getLastInsertID() public méthode

Iterate through all the columns and returns the last insert id of the first column that has a sequence or serial.
public getLastInsertID ( ) : mixed
Résultat mixed last insert id, null if none is found.

getPrimaryKeyCondition() protected méthode

Create the condition and parameters for find by primary.
protected getPrimaryKeyCondition ( $values ) : array
Résultat array tuple($where, $parameters)

getSqlCommand() protected méthode

Build sql command from the criteria. Limit, Offset and Ordering are applied if applicable.
protected getSqlCommand ( TSqlCriteria $criteria ) : TDbCommand
$criteria TSqlCriteria
Résultat TDbCommand command corresponding to the criteria.

getTableInfo() public méthode

public getTableInfo ( ) : TDbTableInfo
Résultat TDbTableInfo

insert() public méthode

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
Résultat 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() public méthode

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() public méthode

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 méthode

protected quoteTuple ( $array ) : string
Résultat string quoted recursive tuple values, e.g. "('val1', 'val2')".

update() public méthode

Updates the table with new data.
public update ( $data, $criteria ) : integer
Résultat integer number of records affected.

updateByPk() public méthode

public updateByPk ( $data, $keys ) : integer
Résultat integer number of records affected.