PHP Class Prado\Data\SqlMap\Statements\TMappedStatement

This class is usualy instantiated during SQLMap configuration by TSqlDomBuilder.
Since: 3.0
Inheritance: extends Prado\TComponent, implements Prado\Data\SqlMap\Statements\IMappedStatement
Mostra file Open project: pradosoft/prado

Public Methods

Method Description
__construct ( TSqlMapManager $sqlMap, TSqlMapStatement $statement ) Creates a new mapped statement.
__sleep ( )
__wakeup ( )
executeInsert ( $connection, $parameter ) : string Execute an insert statement. Fill the parameter object with the ouput parameters if any, also could return the insert generated key.
executeQueryForList ( $connection, $parameter, $result = null, $skip, $max, $delegate = null ) : array Executes the SQL and retuns a List of result objects.
executeQueryForMap ( $connection, $parameter, $keyProperty, $valueProperty = null, $skip, $max, $delegate = null ) : array 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.
executeQueryForObject ( $connection, $parameter, $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.
executeUpdate ( $connection, $parameter ) : integer Execute an update statement. Also used for delete statement.
getCommand ( ) : TPreparedCommand
getID ( ) : string
getManager ( ) : TSqlMapper
getSqlString ( )
getStatement ( ) : TSqlMapStatement
onExecuteQuery ( $sql ) Raise the execute query event.
runQueryForList ( $connection, $parameter, $sql, $result, $delegate = null ) : array Executes the SQL and retuns a List of result objects.
runQueryForMap ( $connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null ) : array 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.
runQueryForObject ( $connection, $command, &$result ) : object Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.

Protected Methods

Method Description
addResultMapGroupBy ( $resultMap, $row, $parent, &$resultObject ) : object ResultMap with GroupBy property. Save object collection graph in a tree and collect the result later.
applyResultMap ( $row, &$resultObject = null ) : object Apply result mapping.
enquequePostSelect ( $select, $resultMap, $property, $row, $resultObject ) Add nested result property to post select queue.
executePostSelect ( $connection ) Process 'select' result properties
executeSQLQueryLimit ( $connection, $command, $max, $skip ) : mixed Execute SQL Query with limits.
executeSelectKey ( $connection, $parameter, $selectKey ) : string Execute the select key statement, used to obtain last insert ID.
fillArrayResultMap ( $resultMap, $row, $resultObject ) : array Retrieve the result map as an array.
fillDefaultResultMap ( $resultMap, $row, $resultObject ) : mixed Fill the result map using default settings. If $resultMap is null the result object returned will be guessed from $resultObject.
fillPropertyWithResultMap ( $resultMap, $row, &$resultObject ) : boolean Fills the property with result mapping results.
fillResultArrayList ( $row, $resultObject ) : object Apply the result to a TList or an array.
fillResultClass ( $resultClass, $row, $resultObject ) : object Fill the result using ResultClass, will creates new result object if required.
fillResultMap ( $resultMapName, $row, $parentGroup = null, &$resultObject = null ) : object Fills the result object according to result mappings.
fillResultObjectProperty ( $row, $resultObject ) : object Apply the result to an object.
getPostGeneratedSelectKey ( $connection, $parameter ) : string Gets the inserted row ID after executing an insert statement.
getPostSelectKeys ( $resultMap, $property, $row ) : array Finds in the post select property the SQL statement primary selection keys.
getPreGeneratedSelectKey ( $connection, $parameter ) : string Gets the insert generated ID before executing an insert statement.
getResultMapGroupKey ( $resultMap, $row ) : string Gets the result 'group by' groupping key for each row.
getScalarResult ( $result, $type ) : mixed Converts the first array value to scalar value of given type.
initialGroupByResults ( ) Empty the group by results cache.
raiseRowDelegate ( $handler, $param ) Raises delegate handler.
setObjectProperty ( $resultMap, $property, $row, &$resultObject ) Set a property of the result object with appropriate value.

Method Details

__construct() public method

Creates a new mapped statement.
public __construct ( TSqlMapManager $sqlMap, TSqlMapStatement $statement )
$sqlMap Prado\Data\SqlMap\TSqlMapManager
$statement Prado\Data\SqlMap\Configuration\TSqlMapStatement

__sleep() public method

public __sleep ( )

__wakeup() public method

public __wakeup ( )

addResultMapGroupBy() protected method

ResultMap with GroupBy property. Save object collection graph in a tree and collect the result later.
protected addResultMapGroupBy ( $resultMap, $row, $parent, &$resultObject ) : object
return object result object.

applyResultMap() protected method

Apply result mapping.
protected applyResultMap ( $row, &$resultObject = null ) : object
return object the result filled with data, null if not filled.

enquequePostSelect() protected method

Add nested result property to post select queue.
protected enquequePostSelect ( $select, $resultMap, $property, $row, $resultObject )

executeInsert() public method

Execute an insert statement. Fill the parameter object with the ouput parameters if any, also could return the insert generated key.
public executeInsert ( $connection, $parameter ) : string
return string the insert generated key.

executePostSelect() protected method

Process 'select' result properties
protected executePostSelect ( $connection )

executeQueryForList() public method

Executes the SQL and retuns a List of result objects.
See also: executeQueryForList()
public executeQueryForList ( $connection, $parameter, $result = null, $skip, $max, $delegate = null ) : array
return array a list of result objects

executeQueryForMap() public method

If valueProperty is null, the entire result object will be entered.
public executeQueryForMap ( $connection, $parameter, $keyProperty, $valueProperty = null, $skip, $max, $delegate = null ) : array
return array An array of object containing the rows keyed by keyProperty.

executeQueryForObject() public method

Executes an SQL statement that returns a single row as an object of the type of the $result passed in as a parameter.
public executeQueryForObject ( $connection, $parameter, $result = null )

executeSQLQueryLimit() protected method

Execute SQL Query with limits.
protected executeSQLQueryLimit ( $connection, $command, $max, $skip ) : mixed
return mixed record set if applicable.

executeSelectKey() protected method

Execute the select key statement, used to obtain last insert ID.
protected executeSelectKey ( $connection, $parameter, $selectKey ) : string
return string last insert ID.

executeUpdate() public method

Return the number of rows effected.
public executeUpdate ( $connection, $parameter ) : integer
return integer The number of rows effected.

fillArrayResultMap() protected method

Retrieve the result map as an array.
protected fillArrayResultMap ( $resultMap, $row, $resultObject ) : array
return array array list of result objects.

fillDefaultResultMap() protected method

Fill the result map using default settings. If $resultMap is null the result object returned will be guessed from $resultObject.
protected fillDefaultResultMap ( $resultMap, $row, $resultObject ) : mixed
return mixed the result object filled with data.

fillPropertyWithResultMap() protected method

Fills the property with result mapping results.
protected fillPropertyWithResultMap ( $resultMap, $row, &$resultObject ) : boolean
return boolean true if the data was found, false otherwise.

fillResultArrayList() protected method

Apply the result to a TList or an array.
protected fillResultArrayList ( $row, $resultObject ) : object
return object result filled with data.

fillResultClass() protected method

Fill the result using ResultClass, will creates new result object if required.
protected fillResultClass ( $resultClass, $row, $resultObject ) : object
return object result object filled with data

fillResultMap() protected method

Fills the result object according to result mappings.
protected fillResultMap ( $resultMapName, $row, $parentGroup = null, &$resultObject = null ) : object
return object result object filled with data.

fillResultObjectProperty() protected method

Apply the result to an object.
protected fillResultObjectProperty ( $row, $resultObject ) : object
return object result filled with data.

getCommand() public method

public getCommand ( ) : TPreparedCommand
return TPreparedCommand command to prepare SQL statements.

getID() public method

public getID ( ) : string
return string Name used to identify the TMappedStatement amongst the others. This the name of the SQL statement by default.

getManager() public method

public getManager ( ) : TSqlMapper
return TSqlMapper The SqlMap used by this MappedStatement

getPostGeneratedSelectKey() protected method

Gets the inserted row ID after executing an insert statement.
protected getPostGeneratedSelectKey ( $connection, $parameter ) : string
return string last insert ID, null otherwise.

getPostSelectKeys() protected method

Finds in the post select property the SQL statement primary selection keys.
protected getPostSelectKeys ( $resultMap, $property, $row ) : array
return array list of primary key values.

getPreGeneratedSelectKey() protected method

Gets the insert generated ID before executing an insert statement.
protected getPreGeneratedSelectKey ( $connection, $parameter ) : string
return string new insert ID if pre-select key statement was executed, null otherwise.

getResultMapGroupKey() protected method

Gets the result 'group by' groupping key for each row.
protected getResultMapGroupKey ( $resultMap, $row ) : string
return string groupping key.

getScalarResult() protected method

Converts the first array value to scalar value of given type.
protected getScalarResult ( $result, $type ) : mixed
return mixed scalar value.

getSqlString() public method

public getSqlString ( )

getStatement() public method

public getStatement ( ) : TSqlMapStatement
return Prado\Data\SqlMap\Configuration\TSqlMapStatement The SQL statment used by this MappedStatement

initialGroupByResults() protected method

Empty the group by results cache.
protected initialGroupByResults ( )

onExecuteQuery() public method

Raise the execute query event.
public onExecuteQuery ( $sql )

raiseRowDelegate() protected method

This method is invoked for each new list item. It is the responsibility of the handler to add the item to the list.
protected raiseRowDelegate ( $handler, $param )

runQueryForList() public method

This method should only be called by internal developers, consider using executeQueryForList() first.
See also: executeQueryForList()
public runQueryForList ( $connection, $parameter, $sql, $result, $delegate = null ) : array
return array a list of result objects

runQueryForMap() public method

If valueProperty is null, the entire result object will be entered. This method should only be called by internal developers, consider using executeQueryForMap() first.
See also: executeQueryForMap()
public runQueryForMap ( $connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null ) : array
return array An array of object containing the rows keyed by keyProperty.

runQueryForObject() public method

This method should only be called by internal developers, consider using executeQueryForObject() first.
See also: executeQueryForObject()
public runQueryForObject ( $connection, $command, &$result ) : object
return object the object.

setObjectProperty() protected method

Set a property of the result object with appropriate value.
protected setObjectProperty ( $resultMap, $property, $row, &$resultObject )