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 TMappedStatement

TMappedStatement class executes SQL mapped statements. Mapped Statements can hold any SQL statement and use Parameter Maps and Result Maps for input and output.

This class is usualy instantiated during SQLMap configuration by TSqlDomBuilder.

TComponent
Extended by TMappedStatement implements IMappedStatement

Direct known subclasses

TInsertMappedStatement, TSelectMappedStatement, TUpdateMappedStatement

Indirect known subclasses

TDeleteMappedStatement
Package: System\Data\SqlMap\Statements
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Since: 3.0
Located at Data/SqlMap/Statements/TMappedStatement.php
Methods summary
public string
# getID( )

Returns

string
Name used to identify the TMappedStatement amongst the others. This the name of the SQL statement by default.

Implementation of

IMappedStatement::getID()
public TSqlMapStatement
# getStatement( )

Returns

TSqlMapStatement
The SQL statment used by this MappedStatement

Implementation of

IMappedStatement::getStatement()
public TSqlMapper
# getManager( )

Returns

TSqlMapper
The SqlMap used by this MappedStatement

Implementation of

IMappedStatement::getManager()
public TPreparedCommand
# getCommand( )

Returns

TPreparedCommand
command to prepare SQL statements.
protected
# initialGroupByResults( )

Empty the group by results cache.

Empty the group by results cache.

public
# __construct( TSqlMapManager $sqlMap, TSqlMapStatement $statement )

Creates a new mapped statement.

Creates a new mapped statement.

Parameters

$sqlMap
TSqlMapper
an sqlmap.
$statement
TSqlMapStatement
An SQL statement.

Overrides

TComponent::__construct()
public
# getSqlString( )
protected mixed
# executeSQLQueryLimit( IDbConnection $connection, array $command, mixed $max, mixed $skip )

Execute SQL Query with limits.

Execute SQL Query with limits.

Parameters

$connection
IDbConnection
database connection
$command
array
SQL statement and parameters.
$max
$skip

Returns

mixed
record set if applicable.

Throws

TSqlMapExecutionException
if execution error or false record set.
TSqlMapQueryExecutionException
if any execution error
public array
# executeQueryForList( IDbConnection $connection, mixed $parameter, object $result = null, integer $skip = -1, integer $max = -1, callable $delegate = null )

Executes the SQL and retuns a List of result objects.

Executes the SQL and retuns a List of result objects.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The object used to set the parameters in the SQL.
$result
object
result collection object.
$skip
integer
The number of rows to skip over.
$max
integer
The maximum number of rows to return.
$delegate
callable
row delegate handler

Returns

array
a list of result objects

See

TMappedStatement::executeQueryForList()

Implementation of

IMappedStatement::executeQueryForList()
public array
# runQueryForList( IDbConnection $connection, mixed $parameter, array $sql, object $result, integer $delegate = null )

Executes the SQL and retuns a List of result objects.

Executes the SQL and retuns a List of result objects.

This method should only be called by internal developers, consider using executeQueryForList() first.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The object used to set the parameters in the SQL.
$sql
array
SQL string and subsititution parameters.
$result
object
result collection object.
$delegate
integer
The number of rows to skip over.

Returns

array
a list of result objects

See

TMappedStatement::executeQueryForList()
public array
# executeQueryForMap( IDbConnection $connection, mixed $parameter, string $keyProperty, string $valueProperty = null, callable $skip = -1, mixed $max = -1, mixed $delegate = null )

Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. The value at each key will be the value of the property specified in the valueProperty parameter. If valueProperty is null, the entire result object will be entered.

Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. The value at each key will be the value of the property specified in the valueProperty parameter. If valueProperty is null, the entire result object will be entered.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The object used to set the parameters in the SQL.
$keyProperty
string
The property of the result object to be used as the key.
$valueProperty
string
The property of the result object to be used as the value (or null).
$skip
callable
row delegate handler
$max
$delegate

Returns

array
An array of object containing the rows keyed by keyProperty.

Implementation of

IMappedStatement::executeQueryForMap()
public array
# runQueryForMap( IDbConnection $connection, mixed $parameter, array $command, string $keyProperty, string $valueProperty = null, callable $delegate = null )

Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. The value at each key will be the value of the property specified in the valueProperty parameter. If valueProperty is null, the entire result object will be entered.

Executes the SQL and retuns all rows selected in a map that is keyed on the property named in the keyProperty parameter. The value at each key will be the value of the property specified in the valueProperty parameter. If valueProperty is null, the entire result object will be entered.

This method should only be called by internal developers, consider using executeQueryForMap() first.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The object used to set the parameters in the SQL.
$command
array
SQL string and subsititution parameters.
$keyProperty
string
The property of the result object to be used as the key.
$valueProperty
string
The property of the result object to be used as the value (or null).
$delegate
callable
row delegate, a callback function

Returns

array
An array of object containing the rows keyed by keyProperty.

See

TMappedStatement::executeQueryForMap()
protected
# raiseRowDelegate( object $handler, mixed $param )

Raises delegate handler. This method is invoked for each new list item. It is the responsibility of the handler to add the item to the list.

Raises delegate handler. This method is invoked for each new list item. It is the responsibility of the handler to add the item to the list.

Parameters

$handler
object
event parameter
$param
public mixed
# executeQueryForObject( IDbConnection $connection, mixed $parameter, mixed $result = null )

Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.

Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The parameter data (object, arrary, primitive) used to set the parameters in the SQL
$result
mixed
The result object.

Returns

mixed
${return}

Implementation of

IMappedStatement::executeQueryForObject()
public object
# runQueryForObject( IDbConnection $connection, array $command, object & $result )

Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.

Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.

This method should only be called by internal developers, consider using executeQueryForObject() first.

Parameters

$connection
IDbConnection
database connection
$command
array
SQL string and subsititution parameters.
$result
object
The result object.

Returns

object
the object.

See

TMappedStatement::executeQueryForObject()
public string
# executeInsert( IDbConnection $connection, mixed $parameter )

Execute an insert statement. Fill the parameter object with the ouput parameters if any, also could return the insert generated key.

Execute an insert statement. Fill the parameter object with the ouput parameters if any, also could return the insert generated key.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The parameter object used to fill the statement.

Returns

string
the insert generated key.
protected string
# getPreGeneratedSelectKey( IDbConnection $connection, mixed $parameter )

Gets the insert generated ID before executing an insert statement.

Gets the insert generated ID before executing an insert statement.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
insert statement parameter.

Returns

string
new insert ID if pre-select key statement was executed, null otherwise.
protected string
# getPostGeneratedSelectKey( IDbConnection $connection, mixed $parameter )

Gets the inserted row ID after executing an insert statement.

Gets the inserted row ID after executing an insert statement.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
insert statement parameter.

Returns

string
last insert ID, null otherwise.
protected string
# executeSelectKey( IDbConnection $connection, mixed $parameter, TSqlMapSelectKey $selectKey )

Execute the select key statement, used to obtain last insert ID.

Execute the select key statement, used to obtain last insert ID.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
insert statement parameter
$selectKey
TSqlMapSelectKey
select key statement

Returns

string
last insert ID.
public integer
# executeUpdate( IDbConnection $connection, mixed $parameter )

Execute an update statement. Also used for delete statement. Return the number of rows effected.

Execute an update statement. Also used for delete statement. Return the number of rows effected.

Parameters

$connection
IDbConnection
database connection
$parameter
mixed
The object used to set the parameters in the SQL.

Returns

integer
The number of rows effected.

Implementation of

IMappedStatement::executeUpdate()
protected
# executePostSelect( IDbConnection $connection )

Process 'select' result properties

Process 'select' result properties

Parameters

$connection
IDbConnection
database connection
public
# onExecuteQuery( array $sql )

Raise the execute query event.

Raise the execute query event.

Parameters

$sql
array
prepared SQL statement and subsititution parameters
protected object
# applyResultMap( array $row, object & $resultObject = null )

Apply result mapping.

Apply result mapping.

Parameters

$row
array
a result set row retrieved from the database
$resultObject
object
the result object, will create if necessary.

Returns

object
the result filled with data, null if not filled.
protected object
# fillResultClass( string $resultClass, array $row, object $resultObject )

Fill the result using ResultClass, will creates new result object if required.

Fill the result using ResultClass, will creates new result object if required.

Parameters

$resultClass
string
result object class name
$row
array
a result set row retrieved from the database
$resultObject
object
the result object, will create if necessary.

Returns

object
result object filled with data
protected object
# fillResultArrayList( array $row, object $resultObject )

Apply the result to a TList or an array.

Apply the result to a TList or an array.

Parameters

$row
array
a result set row retrieved from the database
$resultObject
object
result object, array or list

Returns

object
result filled with data.
protected object
# fillResultObjectProperty( array $row, object $resultObject )

Apply the result to an object.

Apply the result to an object.

Parameters

$row
array
a result set row retrieved from the database
$resultObject
object
result object, array or list

Returns

object
result filled with data.
protected object
# fillResultMap( string $resultMapName, array $row, object $parentGroup = null, mixed & $resultObject = null )

Fills the result object according to result mappings.

Fills the result object according to result mappings.

Parameters

$resultMapName
string
result map name.
$row
array
a result set row retrieved from the database
$parentGroup
object
result object to fill, will create new instances if required.
$resultObject

Returns

object
result object filled with data.
protected object
# addResultMapGroupBy( TResultMap $resultMap, array $row, object $parent, mixed & $resultObject )

ResultMap with GroupBy property. Save object collection graph in a tree and collect the result later.

ResultMap with GroupBy property. Save object collection graph in a tree and collect the result later.

Parameters

$resultMap
TResultMap
result mapping details.
$row
array
a result set row retrieved from the database
$parent
object
the result object
$resultObject

Returns

object
result object.
protected string
# getResultMapGroupKey( TResultMap $resultMap, array $row )

Gets the result 'group by' groupping key for each row.

Gets the result 'group by' groupping key for each row.

Parameters

$resultMap
TResultMap
result mapping details.
$row
array
a result set row retrieved from the database

Returns

string
groupping key.
protected mixed
# fillDefaultResultMap( TResultMap $resultMap, array $row, object $resultObject )

Fill the result map using default settings. If $resultMap is null the result object returned will be guessed from $resultObject.

Fill the result map using default settings. If $resultMap is null the result object returned will be guessed from $resultObject.

Parameters

$resultMap
TResultMap
result mapping details.
$row
array
a result set row retrieved from the database
$resultObject
object
the result object

Returns

mixed
the result object filled with data.
protected array
# fillArrayResultMap( TResultMap $resultMap, array $row, object $resultObject )

Retrieve the result map as an array.

Retrieve the result map as an array.

Parameters

$resultMap
TResultMap
result mapping details.
$row
array
a result set row retrieved from the database
$resultObject
object
the result object

Returns

array
array list of result objects.
protected mixed
# getScalarResult( array $result, string $type )

Converts the first array value to scalar value of given type.

Converts the first array value to scalar value of given type.

Parameters

$result
array
list of results
$type
string
scalar type.

Returns

mixed
scalar value.
protected
# setObjectProperty( TResultMap $resultMap, TResultProperty $property, array $row, object & $resultObject )

Set a property of the result object with appropriate value.

Set a property of the result object with appropriate value.

Parameters

$resultMap
TResultMap
result mapping details.
$property
TResultProperty
the result property to fill.
$row
array
a result set row retrieved from the database
$resultObject
object
the result object
protected
# enquequePostSelect( string $select, TResultMap $resultMap, TResultProperty $property, array $row, object $resultObject )

Add nested result property to post select queue.

Add nested result property to post select queue.

Parameters

$select
string
post select statement ID
$resultMap
TResultMap
current result mapping details.
$property
TResultProperty
current result property.
$row
array
a result set row retrieved from the database
$resultObject
object
the result object
protected array
# getPostSelectKeys( TResultMap $resultMap, TResultProperty $property, array $row )

Finds in the post select property the SQL statement primary selection keys.

Finds in the post select property the SQL statement primary selection keys.

Parameters

$resultMap
TResultMap
result mapping details
$property
TResultProperty
result property
$row
array
current row data.

Returns

array
list of primary key values.
protected boolean
# fillPropertyWithResultMap( TResultMap $resultMap, array $row, object & $resultObject )

Fills the property with result mapping results.

Fills the property with result mapping results.

Parameters

$resultMap
TResultMap
nested result mapping details.
$row
array
a result set row retrieved from the database
$resultObject
object
the result object

Returns

boolean
true if the data was found, false otherwise.
public
# __wakeup( )

Do not call this method. This is a PHP magic method that will be called automatically after any unserialization; it can perform reinitialization tasks on the object.

Do not call this method. This is a PHP magic method that will be called automatically after any unserialization; it can perform reinitialization tasks on the object.

Overrides

TComponent::__wakeup()
public
# __sleep( )

Returns an array with the names of all variables of that object that should be serialized. Do not call this method. This is a PHP magic method that will be called automatically prior to any serialization.

Returns an array with the names of all variables of that object that should be serialized. Do not call this method. This is a PHP magic method that will be called automatically prior to any serialization.

Overrides

TComponent::__sleep()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __unset(), 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
Post QUERY_FOR_LIST 0
#

select is to query for list.

select is to query for list.

Post QUERY_FOR_ARRAY 1
#

select is to query for list.

select is to query for list.

Post QUERY_FOR_OBJECT 2
#

select is to query for object.

select is to query for object.

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