|
Class TSqlMapGateway
DataMapper client, a fascade to provide access the rest of the DataMapper
framework. It provides three core functions:
# execute an update query (including insert and delete). # execute a select
query for a single object # execute a select query for a list of objects
This class should be instantiated from a TSqlMapManager instance.
-
TComponent
-
TSqlMapGateway
Methods summary
public
|
#
__construct( mixed $manager )
The common __construct If desired by the new object, this will auto install
and listen to global event functions as defined by the object via 'fx' methods.
This also attaches any predefined behaviors. This function installs all class
behaviors in a class hierarchy from the deepest subclass through each parent to
the top most class, TComponent.
The common __construct If desired by the new object, this will auto install
and listen to global event functions as defined by the object via 'fx' methods.
This also attaches any predefined behaviors. This function installs all class
behaviors in a class hierarchy from the deepest subclass through each parent to
the top most class, TComponent.
Overrides
|
public
TSqlMapManager
|
|
public
TDbConnection
|
|
public
object
|
#
queryForObject( string $statementName, mixed $parameter = null, mixed $result = null )
Executes a Sql SELECT statement that returns that returns data to populate a
single object instance.
Executes a Sql SELECT statement that returns that returns data to populate a
single object instance.
The parameter object is generally used to supply the input data for the WHERE
clause parameter(s) of the SELECT statement.
Parameters
- $statementName
string The name of the sql statement to execute.
- $parameter
mixed The object used to set the parameters in the SQL.
- $result
mixed An object of the type to be returned.
Returns
object A single result object populated with the result set data.
|
public
TList
|
#
queryForList( string $statementName, mixed $parameter = null, TList $result = null, integer $skip = -1, integer $max = -1 )
Executes a Sql SELECT statement that returns data to populate a number of
result objects.
Executes a Sql SELECT statement that returns data to populate a number of
result objects.
The parameter object is generally used to supply the input data for the WHERE
clause parameter(s) of the SELECT statement.
Parameters
- $statementName
string The name of the sql statement to execute.
- $parameter
mixed The object used to set the parameters in the SQL.
- $result
TList
An Ilist object used to hold the objects, pass in null if want to return a list
instead.
- $skip
integer The number of rows to skip over.
- $max
integer The maximum number of rows to return.
Returns
TList
A List of result objects.
|
public
TList
|
#
queryWithRowDelegate( string $statementName, callable $delegate, mixed $parameter = null, TList $result = null, integer $skip = -1, integer $max = -1 )
Runs a query for list with a custom object that gets a chance to deal with
each row as it is processed.
Runs a query for list with a custom object that gets a chance to deal with
each row as it is processed.
Example: $sqlmap->queryWithRowDelegate('getAccounts', array($this,
'rowHandler'));
Parameters
- $statementName
string The name of the sql statement to execute.
- $delegate
callable Row delegate handler, a valid callback required.
- $parameter
mixed The object used to set the parameters in the SQL.
- $result
TList
An Ilist object used to hold the objects, pass in null if want to return a list
instead.
- $skip
integer The number of rows to skip over.
- $max
integer The maximum number of rows to return.
Returns
TList
A List of result objects.
|
public
TPagedList
|
#
queryForPagedList( string $statementName, mixed $parameter = null, integer $pageSize = 10, integer $page = 0 )
Executes the SQL and retuns a subset of the results in a dynamic TPagedList
that can be used to automatically scroll through results from a database
table.
Executes the SQL and retuns a subset of the results in a dynamic TPagedList
that can be used to automatically scroll through results from a database
table.
Parameters
- $statementName
string The name of the sql statement to execute.
- $parameter
mixed The object used to set the parameters in the SQL.
- $pageSize
integer The maximum number of objects to store in each page.
- $page
integer The number of the page to initially load into the list.
Returns
TPagedList
A PaginatedList of beans containing the rows.
|
public
TPagedList
|
#
queryForPagedListWithRowDelegate( string $statementName, callable $delegate, mixed $parameter = null, integer $pageSize = 10, integer $page = 0 )
Executes the SQL and retuns a subset of the results in a dynamic TPagedList
that can be used to automatically scroll through results from a database
table.
Executes the SQL and retuns a subset of the results in a dynamic TPagedList
that can be used to automatically scroll through results from a database
table.
Runs paged list query with row delegate Example:
$sqlmap->queryForPagedListWithRowDelegate('getAccounts', array($this,
'rowHandler'));
Parameters
- $statementName
string The name of the sql statement to execute.
- $delegate
callable Row delegate handler, a valid callback required.
- $parameter
mixed The object used to set the parameters in the SQL.
- $pageSize
integer The maximum number of objects to store in each page.
- $page
integer The number of the page to initially load into the list.
Returns
TPagedList
A PaginatedList of beans containing the rows.
|
public
TMap
|
#
queryForMap( string $statementName, mixed $parameter = null, string $keyProperty = null, string $valueProperty = null, mixed $skip = -1, mixed $max = -1 )
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
- $statementName
string The name of the sql statement to execute.
- $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.
- $skip
- $max
Returns
TMap
Array object containing the rows keyed by keyProperty.
|
public
TMap
|
#
queryForMapWithRowDelegate( string $statementName, callable $delegate, mixed $parameter = null, string $keyProperty = null, string $valueProperty = null, mixed $skip = -1, mixed $max = -1 )
Runs a query with a custom object that gets a chance to deal with each row as
it is processed.
Runs a query with a custom object that gets a chance to deal with each row as
it is processed.
Example: $sqlmap->queryForMapWithRowDelegate('getAccounts', array($this,
'rowHandler'));
Parameters
- $statementName
string The name of the sql statement to execute.
- $delegate
callable Row delegate handler, a valid callback required.
- $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.
- $skip
- $max
Returns
TMap
Array object containing the rows keyed by keyProperty.
|
public
mixed
|
#
insert( string $statementName, string $parameter = null )
Executes a Sql INSERT statement.
Executes a Sql INSERT statement.
Insert is a bit different from other update methods, as it provides
facilities for returning the primary key of the newly inserted row (rather than
the effected rows),
The parameter object is generally used to supply the input data for the
INSERT values.
Parameters
- $statementName
string The name of the statement to execute.
- $parameter
string The parameter object.
Returns
mixed The primary key of the newly inserted row. This might be automatically generated
by the RDBMS, or selected from a sequence table or other source.
|
public
integer
|
#
update( string $statementName, mixed $parameter = null )
Executes a Sql UPDATE statement.
Executes a Sql UPDATE statement.
Update can also be used for any other update statement type, such as inserts
and deletes. Update returns the number of rows effected.
The parameter object is generally used to supply the input data for the
UPDATE values as well as the WHERE clause parameter(s).
Parameters
- $statementName
string The name of the statement to execute.
- $parameter
mixed The parameter object.
Returns
integer The number of rows effected.
|
public
integer
|
#
delete( string $statementName, mixed $parameter = null )
Executes a Sql DELETE statement. Delete returns the number of rows
effected.
Executes a Sql DELETE statement. Delete returns the number of rows
effected.
Parameters
- $statementName
string The name of the statement to execute.
- $parameter
mixed The parameter object.
Returns
integer The number of rows effected.
|
public
|
#
flushCaches( )
Flushes all cached objects that belong to this SqlMap
Flushes all cached objects that belong to this SqlMap
|
public
|
|
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()
|
|