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 TActiveRecordGateway

TActiveRecordGateway excutes the SQL command queries and returns the data record as arrays (for most finder methods).

TComponent
Extended by TActiveRecordGateway
Package: System\Data\ActiveRecord
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizho[at]gmail[dot]com>
Since: 3.1
Located at Data/ActiveRecord/TActiveRecordGateway.php
Methods summary
public
# __construct( TActiveRecordManager $manager )

Record gateway constructor.

Record gateway constructor.

Parameters

$manager
TActiveRecordManager
$manager

Overrides

TComponent::__construct()
protected TActiveRecordManager
# getManager( )

Returns

TActiveRecordManager
record manager.
protected string
# getRecordTableName( TActiveRecord $record )

Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.

Gets the table name from the 'TABLE' constant of the active record class if defined, otherwise use the class name as table name.

Parameters

$record
TActiveRecord
active record instance

Returns

string
table name for the given record class.
public TDbTableInfo
# getRecordTableInfo( TActiveRecord $record )

Returns table information, trys the application cache first.

Returns table information, trys the application cache first.

Parameters

$record
TActiveRecord
$record

Returns

TDbTableInfo
table information.
public TDbTableInfo
# getTableInfo( TDbConnection $connection, string $tableName )

Returns table information for table in the database connection.

Returns table information for table in the database connection.

Parameters

$connection
TDbConnection
database connection
$tableName
string
table name

Returns

TDbTableInfo
table details.
public TDataGatewayCommand
# getCommand( TActiveRecord $record )

Parameters

$record
TActiveRecord
$record

Returns

TDataGatewayCommand
public
# onCreateCommand( TDataGatewayCommand $sender, TDataGatewayEventParameter $param )

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. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.

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. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.

Parameters

$sender
TDataGatewayCommand
originator $sender
$param
TDataGatewayEventParameter
public
# onExecuteCommand( TDataGatewayCommand $sender, TDataGatewayResultEventParameter $param )

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. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.

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. This method also raises the OnCreateCommand event on the ActiveRecord object calling this gateway.

Parameters

$sender
TDataGatewayCommand
originator $sender
$param
TDataGatewayResultEventParameter
public array
# findRecordByPK( TActiveRecord $record, array $keys )

Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.

Returns record data matching the given primary key(s). If the table uses composite key, specify the name value pairs as an array.

Parameters

$record
TActiveRecord
active record instance.
$keys
array
primary name value pairs

Returns

array
record data
public array
# findRecordsByPks( TActiveRecord $record, array $keys )

Returns records matching the list of given primary keys.

Returns records matching the list of given primary keys.

Parameters

$record
TActiveRecord
active record instance.
$keys
array
list of primary name value pairs

Returns

array
matching data.
public mixed
# findRecordsByCriteria( TActiveRecord $record, TActiveRecordCriteria $criteria, boolean $iterator = false )

Returns record data matching the given critera. If $iterator is true, it will return multiple rows as TDbDataReader otherwise it returns the first row data.

Returns record data matching the given critera. If $iterator is true, it will return multiple rows as TDbDataReader otherwise it returns the first row data.

Parameters

$record
TActiveRecord
active record finder instance.
$criteria
TActiveRecordCriteria
search criteria.
$iterator
boolean
true to return multiple rows as iterator, false returns first row.

Returns

mixed
matching data.
public array
# findRecordBySql( TActiveRecord $record, TActiveRecordCriteria $criteria )

Return record data from sql query.

Return record data from sql query.

Parameters

$record
TActiveRecord
active record finder instance.
$criteria
TActiveRecordCriteria
sql query

Returns

array
result.
public TDbDataReader
# findRecordsBySql( TActiveRecord $record, TActiveRecordCriteria $criteria )

Return record data from sql query.

Return record data from sql query.

Parameters

$record
TActiveRecord
active record finder instance.
$criteria
TActiveRecordCriteria
sql query

Returns

TDbDataReader
result iterator.
public
# findRecordsByIndex( TActiveRecord $record, mixed $criteria, mixed $fields, mixed $values )
public integer
# countRecords( TActiveRecord $record, TActiveRecordCriteria $criteria )

Returns the number of records that match the given criteria.

Returns the number of records that match the given criteria.

Parameters

$record
TActiveRecord
active record finder instance.
$criteria
TActiveRecordCriteria
search criteria

Returns

integer
number of records.
public integer
# insert( TActiveRecord $record )

Insert a new record.

Insert a new record.

Parameters

$record
TActiveRecord
new record.

Returns

integer
number of rows affected.
protected
# updatePostInsert( TActiveRecord $record )

Sets the last insert ID to the corresponding property of the record if available.

Sets the last insert ID to the corresponding property of the record if available.

Parameters

$record
TActiveRecord
record for insertion
protected array
# getInsertValues( TActiveRecord $record )

Parameters

$record
TActiveRecord
record

Returns

array
insert values.
public integer
# update( TActiveRecord $record )

Update the record.

Update the record.

Parameters

$record
TActiveRecord
dirty record.

Returns

integer
number of rows affected.
protected
# getUpdateValues( TActiveRecord $record )
protected
# updateAssociatedRecords( TActiveRecord $record, mixed $updateBelongsTo = false )
public integer
# delete( TActiveRecord $record )

Delete the record.

Delete the record.

Parameters

$record
TActiveRecord
record to be deleted.

Returns

integer
number of rows affected.
protected
# getPrimaryKeyValues( TActiveRecord $record )
public integer
# deleteRecordsByPk( TActiveRecord $record, mixed $keys )

Delete multiple records using primary keys.

Delete multiple records using primary keys.

Parameters

$record
TActiveRecord
finder instance.
$keys

Returns

integer
number of rows deleted.
public integer
# deleteRecordsByCriteria( TActiveRecord $record, TActiveRecordCriteria $criteria )

Delete multiple records by criteria.

Delete multiple records by criteria.

Parameters

$record
TActiveRecord
active record finder instance.
$criteria
TActiveRecordCriteria
search criteria

Returns

integer
number of records.
protected
# raiseCommandEvent( string $event, TDbCommand $command, TActiveRecord $record, TActiveRecordCriteria $criteria )

Raise the corresponding command event, insert, update, delete or select.

Raise the corresponding command event, insert, update, delete or select.

Parameters

$event
string
command type
$command
TDbCommand
sql command to be executed.
$record
TActiveRecord
active record
$criteria
TActiveRecordCriteria
data for the command.
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 summary
string TABLE_CONST 'TABLE'
#

Constant name for specifying optional table name in TActiveRecord.

Constant name for specifying optional table name in TActiveRecord.

string TABLE_METHOD 'table'
#

Method name for returning optional table name in in TActiveRecord

Method name for returning optional table name in in TActiveRecord

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