PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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
Extended by TDataGatewayCommand
Package: System\Data\DataGateway
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizho[at]gmail[dot]com>
Version: $Id$
Since: 3.1
Located at Data/DataGateway/TDataGatewayCommand.php
Methods summary
public
# __construct( TDbCommandBuilder $builder )

Parameters

$builder
TDbCommandBuilder
database specific database command builder.

Overrides

TComponent::__construct()
public TDbTableInfo
# getTableInfo( )

Returns

TDbTableInfo
public TDbConnection
# getDbConnection( )

Returns

TDbConnection
public TDbCommandBuilder
# getBuilder( )

Returns

TDbCommandBuilder
public integer
# delete( TSqlCriteria $criteria )

Executes a delete command.

Executes a delete command.

Parameters

$criteria
TSqlCriteria
delete conditions and 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

$criteria
TSqlCriteria
find conditions and parameters.

Returns

array
matching record.
public TDbDataReader
# findAll( TSqlCriteria $criteria )

Find one or more matching records.

Find one or more matching records.

Parameters

$criteria
TSqlCriteria
$criteria

Returns

TDbDataReader
record reader.
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

$criteria
TSqlCriteria
$criteria

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

TDbDataReader
record reader.
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

$array
TDbConnection
database connection.

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

$criteria
TSqlCriteria
$criteria

Returns

TDbDataReader
record reader.
public TDbDataReader
# findAllBySql( TSqlCriteria $criteria )

Find zero or more matching records for arbituary SQL.

Find zero or more matching records for arbituary SQL.

Parameters

$criteria
TSqlCriteria
$criteria

Returns

TDbDataReader
record reader.
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

$criteria
TSqlCriteria
$criteria

Returns

TDbCommand
command corresponding to the criteria.
public integer
# count( TSqlCriteria $criteria )

Parameters

$criteria
TSqlCriteria
$criteria

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

TActiveRecordCriteria
criteria created from the method name and its arguments.
protected array
# extractMatchingConditions( string $method, string $condition )

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

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

Parameters

$method
string
dynamic method name
$condition
string
dynamic method search criteria

Returns

array
search condition substrings
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

$command
TDataGatewayCommand
originator $sender
$criteria
TDataGatewayEventParameter
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

$command
TDataGatewayCommand
originator $sender
$result
TDataGatewayResultEventParameter
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()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO