Class TMappedStatement

Description

Implements interfaces:

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.

  • since: 3.0
  • version: $Id: TMappedStatement.php 2384 2008-02-26 16:58:20Z tof $
  • author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /Data/SqlMap/Statements/TMappedStatement.php (line 24)

TComponent
   |
   --TMappedStatement
Direct descendents
Class Description
TInsertMappedStatement TInsertMappedStatement class.
TSelectMappedStatement TSelectMappedStatment class.
TUpdateMappedStatement TUpdateMappedStatement class.
Class Constant Summary
Method Summary
TMappedStatement __construct (TSqlMapManager $sqlMap, TSqlMapStatement $statement)
object result addResultMapGroupBy (TResultMap $resultMap, array $row, object the $parent, mixed &$resultObject)
object the applyResultMap (array $row, [object the &$resultObject = null])
void enquequePostSelect (string $select, TResultMap $resultMap, TResultProperty $property, array $row, object the $resultObject)
string executeInsert (IDbConnection $connection, mixed $parameter)
void executePostSelect (IDbConnection $connection)
array executeQueryForList (IDbConnection $connection, mixed $parameter, [object result $result = null], [integer $skip = -1], [integer $max = -1], [callback $delegate = null])
array executeQueryForMap (IDbConnection $connection, mixed $parameter, string $keyProperty, [string $valueProperty = null], [callback $skip = -1], [mixed $max = -1], [mixed $delegate = null])
${return} executeQueryForObject (IDbConnection $connection, mixed $parameter, [mixed $result = null])
string executeSelectKey (IDbConnection $connection, mixed $parameter, TSqlMapSelectKey $selectKey)
mixed executeSQLQueryLimit (IDbConnection $connection, array $command, mixed $max, mixed $skip)
integer executeUpdate (IDbConnection $connection, mixed $parameter)
array fillArrayResultMap (TResultMap $resultMap, array $row, object the $resultObject)
mixed fillDefaultResultMap (TResultMap $resultMap, array $row, object the $resultObject)
boolean fillPropertyWithResultMap (TResultMap $resultMap, array $row, object the &$resultObject)
object result fillResultArrayList (array $row, object result $resultObject)
object result fillResultClass (string $resultClass, array $row, object the $resultObject)
object result fillResultMap (string $resultMapName, array $row, [object result $parentGroup = null], [mixed &$resultObject = null])
object result fillResultObjectProperty (array $row, object result $resultObject)
string getID ()
TSqlMapper getManager ()
string getPostGeneratedSelectKey (IDbConnection $connection, mixed $parameter)
array getPostSelectKeys (TResultMap $resultMap, TResultProperty $property, array $row)
string getPreGeneratedSelectKey (IDbConnection $connection, mixed $parameter)
string getResultMapGroupKey (TResultMap $resultMap, array $row)
mixed getScalarResult (array $result, string $type)
void getSqlString ()
void onExecuteQuery (array $sql)
void raiseRowDelegate (object event $handler, mixed $param)
array runQueryForList (IDbConnection $connection, mixed $parameter, array $sql, object result $result, [integer $delegate = null], integer 5, callback 6)
array runQueryForMap (IDbConnection $connection, mixed $parameter, array $command, string $keyProperty, [string $valueProperty = null], [callback $delegate = null])
object the runQueryForObject (IDbConnection $connection, array $command, object The &$result)
void setObjectProperty (TResultMap $resultMap, TResultProperty $property, array $row, object the &$resultObject)
Methods
Constructor __construct (line 117)

Creates a new mapped statement.

  • access: public
TMappedStatement __construct (TSqlMapManager $sqlMap, TSqlMapStatement $statement)
addResultMapGroupBy (line 672)

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

  • return: object.
  • access: protected
object result addResultMapGroupBy (TResultMap $resultMap, array $row, object the $parent, mixed &$resultObject)
  • TResultMap $resultMap: result mapping details.
  • array $row: a result set row retrieved from the database
  • object the $parent: result object
applyResultMap (line 549)

Apply result mapping.

  • return: result filled with data, null if not filled.
  • access: protected
object the applyResultMap (array $row, [object the &$resultObject = null])
  • array $row: a result set row retrieved from the database
  • object the &$resultObject: result object, will create if necessary.
enquequePostSelect (line 844)

Add nested result property to post select queue.

  • access: protected
void enquequePostSelect (string $select, TResultMap $resultMap, TResultProperty $property, array $row, object the $resultObject)
  • string $select: post select statement ID
  • TResultMap $resultMap: current result mapping details.
  • TResultProperty $property: current result property.
  • array $row: a result set row retrieved from the database
  • object the $resultObject: result object
executeInsert (line 421)

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

  • return: the insert generated key.
  • access: public
string executeInsert (IDbConnection $connection, mixed $parameter)
  • IDbConnection $connection: database connection
  • mixed $parameter: The parameter object used to fill the statement.

Redefined in descendants as:
executePostSelect (line 507)

Process 'select' result properties

  • access: protected
void executePostSelect (IDbConnection $connection)
  • IDbConnection $connection: database connection
executeQueryForList (line 204)

Executes the SQL and retuns a List of result objects.

array executeQueryForList (IDbConnection $connection, mixed $parameter, [object result $result = null], [integer $skip = -1], [integer $max = -1], [callback $delegate = null])
  • IDbConnection $connection: database connection
  • mixed $parameter: The object used to set the parameters in the SQL.
  • object result $result: collection object.
  • integer $skip: The number of rows to skip over.
  • integer $max: The maximum number of rows to return.
  • callback $delegate: row delegate handler

Redefined in descendants as:
executeQueryForMap (line 277)

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.

  • return: An array of object containing the rows keyed by keyProperty.
  • access: public
array executeQueryForMap (IDbConnection $connection, mixed $parameter, string $keyProperty, [string $valueProperty = null], [callback $skip = -1], [mixed $max = -1], [mixed $delegate = null])
  • IDbConnection $connection: database connection
  • mixed $parameter: The object used to set the parameters in the SQL.
  • string $keyProperty: The property of the result object to be used as the key.
  • string $valueProperty: The property of the result object to be used as the value (or null).
  • callback $skip: row delegate handler

Redefined in descendants as:
executeQueryForObject (line 375)

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

  • access: public
${return} executeQueryForObject (IDbConnection $connection, mixed $parameter, [mixed $result = null])
  • IDbConnection $connection: database connection
  • mixed $parameter: The parameter data (object, arrary, primitive) used to set the parameters in the SQL
  • mixed $result: The result object.

Redefined in descendants as:
executeSelectKey (line 476)

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

  • return: last insert ID.
  • access: protected
string executeSelectKey (IDbConnection $connection, mixed $parameter, TSqlMapSelectKey $selectKey)
  • IDbConnection $connection: database connection
  • mixed $parameter: insert statement parameter
  • TSqlMapSelectKey $selectKey: select key statement
executeSQLQueryLimit (line 164)

Execute SQL Query with limits.

  • return: record set if applicable.
  • access: protected
  • throws: TSqlMapExecutionException if execution error or false record set.
  • throws: TSqlMapQueryExecutionException if any execution error
mixed executeSQLQueryLimit (IDbConnection $connection, array $command, mixed $max, mixed $skip)
  • IDbConnection $connection: database connection
  • array $command: SQL statement and parameters.
executeUpdate (line 493)

Execute an update statement. Also used for delete statement.

Return the number of rows effected.

  • return: The number of rows effected.
  • access: public
integer executeUpdate (IDbConnection $connection, mixed $parameter)
  • IDbConnection $connection: database connection
  • mixed $parameter: The object used to set the parameters in the SQL.

Redefined in descendants as:
fillArrayResultMap (line 759)

Retrieve the result map as an array.

  • return: array list of result objects.
  • access: protected
array fillArrayResultMap (TResultMap $resultMap, array $row, object the $resultObject)
  • TResultMap $resultMap: result mapping details.
  • array $row: a result set row retrieved from the database
  • object the $resultObject: result object
fillDefaultResultMap (line 735)

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

  • return: the result object filled with data.
  • access: protected
mixed fillDefaultResultMap (TResultMap $resultMap, array $row, object the $resultObject)
  • TResultMap $resultMap: result mapping details.
  • array $row: a result set row retrieved from the database
  • object the $resultObject: result object
fillPropertyWithResultMap (line 909)

Fills the property with result mapping results.

  • return: true if the data was found, false otherwise.
  • access: protected
boolean fillPropertyWithResultMap (TResultMap $resultMap, array $row, object the &$resultObject)
  • TResultMap $resultMap: nested result mapping details.
  • array $row: a result set row retrieved from the database
  • object the &$resultObject: result object
fillResultArrayList (line 598)

Apply the result to a TList or an array.

  • return: filled with data.
  • access: protected
object result fillResultArrayList (array $row, object result $resultObject)
  • array $row: a result set row retrieved from the database
  • object result $resultObject: object, array or list
fillResultClass (line 576)

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

  • return: object filled with data
  • access: protected
object result fillResultClass (string $resultClass, array $row, object the $resultObject)
  • string $resultClass: result object class name
  • array $row: a result set row retrieved from the database
  • object the $resultObject: result object, will create if necessary.
fillResultMap (line 640)

Fills the result object according to result mappings.

  • return: object filled with data.
  • access: protected
object result fillResultMap (string $resultMapName, array $row, [object result $parentGroup = null], [mixed &$resultObject = null])
  • string $resultMapName: result map name.
  • array $row: a result set row retrieved from the database
  • object result $parentGroup: object to fill, will create new instances if required.
fillResultObjectProperty (line 615)

Apply the result to an object.

  • return: filled with data.
  • access: protected
object result fillResultObjectProperty (array $row, object result $resultObject)
  • array $row: a result set row retrieved from the database
  • object result $resultObject: object, array or list
getCommand (line 99)
  • return: command to prepare SQL statements.
  • access: public
TPreparedCommand getCommand ()
getID (line 75)
  • return: Name used to identify the TMappedStatement amongst the others. This the name of the SQL statement by default.
  • access: public
string getID ()
getManager (line 91)
  • return: The SqlMap used by this MappedStatement
  • access: public
TSqlMapper getManager ()
getPostGeneratedSelectKey (line 459)

Gets the inserted row ID after executing an insert statement.

  • return: last insert ID, null otherwise.
  • access: protected
string getPostGeneratedSelectKey (IDbConnection $connection, mixed $parameter)
  • IDbConnection $connection: database connection
  • mixed $parameter: insert statement parameter.
getPostSelectKeys (line 882)

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

  • return: list of primary key values.
  • access: protected
array getPostSelectKeys (TResultMap $resultMap, TResultProperty $property, array $row)
getPreGeneratedSelectKey (line 443)

Gets the insert generated ID before executing an insert statement.

  • return: new insert ID if pre-select key statement was executed, null otherwise.
  • access: protected
string getPreGeneratedSelectKey (IDbConnection $connection, mixed $parameter)
  • IDbConnection $connection: database connection
  • mixed $parameter: insert statement parameter.
getResultMapGroupKey (line 718)

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

  • return: groupping key.
  • access: protected
string getResultMapGroupKey (TResultMap $resultMap, array $row)
  • TResultMap $resultMap: result mapping details.
  • array $row: a result set row retrieved from the database
getScalarResult (line 779)

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

  • return: scalar value.
  • access: protected
mixed getScalarResult (array $result, string $type)
  • array $result: list of results
  • string $type: scalar type.
getSqlString (line 125)
  • access: public
void getSqlString ()
getStatement (line 83)
  • return: The SQL statment used by this MappedStatement
  • access: public
TSqlMapStatement getStatement ()
initialGroupByResults (line 107)

Empty the group by results cache.

  • access: protected
void initialGroupByResults ()
onExecuteQuery (line 538)

Raise the execute query event.

  • access: public
void onExecuteQuery (array $sql)
  • array $sql: prepared SQL statement and subsititution parameters
raiseRowDelegate (line 341)

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.

  • access: protected
void raiseRowDelegate (object event $handler, mixed $param)
  • object event $handler: parameter
runQueryForList (line 226)

Executes the SQL and retuns a List of result objects.

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

array runQueryForList (IDbConnection $connection, mixed $parameter, array $sql, object result $result, [integer $delegate = null], integer 5, callback 6)
  • integer 5: The maximum number of rows to return.
  • callback 6: row delegate handler
  • IDbConnection $connection: database connection
  • mixed $parameter: The object used to set the parameters in the SQL.
  • array $sql: SQL string and subsititution parameters.
  • object result $result: collection object.
  • integer $delegate: The number of rows to skip over.
runQueryForMap (line 301)

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 <tt>executeQueryForMap()</tt> first.

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

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

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

object the runQueryForObject (IDbConnection $connection, array $command, object The &$result)
  • IDbConnection $connection: database connection
  • array $command: SQL string and subsititution parameters.
  • object The &$result: result object.
setObjectProperty (line 793)

Set a property of the result object with appropriate value.

  • access: protected
void setObjectProperty (TResultMap $resultMap, TResultProperty $property, array $row, object the &$resultObject)
  • TResultMap $resultMap: result mapping details.
  • TResultProperty $property: the result property to fill.
  • array $row: a result set row retrieved from the database
  • object the &$resultObject: result object

Inherited Methods

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants
QUERY_FOR_ARRAY = 1 (line 64)
  • var: select is to query for list.
QUERY_FOR_LIST = 0 (line 59)
  • var: select is to query for list.
QUERY_FOR_OBJECT = 2 (line 69)
  • var: select is to query for object.

Documentation generated on Mon, 21 Apr 2008 11:35:35 -0400 by phpDocumentor 1.3.0RC4