Class TSqlMapGateway

Description

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.

  • since: 3.1
  • version: $Id: TSqlMapGateway.php 1911 2007-05-08 08:06:13Z wei $
  • author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Located in /Data/SqlMap/TSqlMapGateway.php (line 30)

TComponent
   |
   --TSqlMapGateway
Method Summary
TSqlMapGateway __construct (mixed $manager)
integer delete (string $statementName, [mixed $parameter = null])
void flushCaches ()
mixed insert (string $statementName, [string $parameter = null])
TList queryForList (string $statementName, [mixed $parameter = null], [TList $result = null], [int $skip = -1], [int $max = -1])
TMap queryForMap (string $statementName, [mixed $parameter = null], [string $keyProperty = null], [string $valueProperty = null], [mixed $skip = -1], [mixed $max = -1])
TMap queryForMapWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [string $keyProperty = null], [string $valueProperty = null], [mixed $skip = -1], [mixed $max = -1])
object A queryForObject (string $statementName, [mixed $parameter = null], [mixed $result = null])
TPagedList queryForPagedList (string $statementName, [mixed $parameter = null], [integer $pageSize = 10])
TPagedList queryForPagedListWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [integer $pageSize = 10])
TList queryWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [TList $result = null], [int $skip = -1], [int $max = -1])
integer update (string $statementName, [mixed $parameter = null])
Methods
Constructor __construct (line 37)
  • access: public
TSqlMapGateway __construct (mixed $manager)
delete (line 238)

Executes a Sql DELETE statement. Delete returns the number of rows effected.

  • return: The number of rows effected.
  • access: public
integer delete (string $statementName, [mixed $parameter = null])
  • string $statementName: The name of the statement to execute.
  • mixed $parameter: The parameter object.
flushCaches (line 246)

Flushes all cached objects that belong to this SqlMap

  • access: public
void flushCaches ()
getDbConnection (line 53)
  • return: database connection.
  • access: public
TDbConnection getDbConnection ()
getSqlMapManager (line 45)
  • return: sqlmap manager.
  • access: public
TSqlMapManager getSqlMapManager ()
insert (line 207)

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.

  • return: 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.
  • access: public
mixed insert (string $statementName, [string $parameter = null])
  • string $statementName: The name of the statement to execute.
  • string $parameter: The parameter object.
queryForList (line 91)

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.

  • return: A List of result objects.
  • access: public
TList queryForList (string $statementName, [mixed $parameter = null], [TList $result = null], [int $skip = -1], [int $max = -1])
  • string $statementName: The name of the sql statement to execute.
  • mixed $parameter: The object used to set the parameters in the SQL.
  • TList $result: An Ilist object used to hold the objects, pass in null if want to return a list instead.
  • int $skip: The number of rows to skip over.
  • int $max: The maximum number of rows to return.
queryForMap (line 166)

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: Array object containing the rows keyed by keyProperty.
  • access: public
TMap queryForMap (string $statementName, [mixed $parameter = null], [string $keyProperty = null], [string $valueProperty = null], [mixed $skip = -1], [mixed $max = -1])
  • string $statementName: The name of the sql statement to execute.
  • 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.
queryForMapWithRowDelegate (line 185)

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'));

  • return: Array object containing the rows keyed by keyProperty.
  • access: public
TMap queryForMapWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [string $keyProperty = null], [string $valueProperty = null], [mixed $skip = -1], [mixed $max = -1])
  • string $statementName: The name of the sql statement to execute.
  • callback $delegate: Row delegate handler, a valid callback required.
  • 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.
queryForObject (line 70)

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.

  • return: single result object populated with the result set data.
  • access: public
object A queryForObject (string $statementName, [mixed $parameter = null], [mixed $result = null])
  • string $statementName: The name of the sql statement to execute.
  • mixed $parameter: The object used to set the parameters in the SQL.
  • mixed $result: An object of the type to be returned.
queryForPagedList (line 127)

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.

  • return: A PaginatedList of beans containing the rows.
  • access: public
TPagedList queryForPagedList (string $statementName, [mixed $parameter = null], [integer $pageSize = 10])
  • string $statementName: The name of the sql statement to execute.
  • mixed $parameter: The object used to set the parameters in the SQL.
  • integer $pageSize: The maximum number of objects to store in each page.
queryForPagedListWithRowDelegate (line 147)

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'));

  • return: A PaginatedList of beans containing the rows.
  • access: public
TPagedList queryForPagedListWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [integer $pageSize = 10])
  • string $statementName: The name of the sql statement to execute.
  • callback $delegate: Row delegate handler, a valid callback required.
  • mixed $parameter: The object used to set the parameters in the SQL.
  • integer $pageSize: The maximum number of objects to store in each page.
queryWithRowDelegate (line 112)

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'));

  • return: A List of result objects.
  • access: public
TList queryWithRowDelegate (string $statementName, callback $delegate, [mixed $parameter = null], [TList $result = null], [int $skip = -1], [int $max = -1])
  • string $statementName: The name of the sql statement to execute.
  • callback $delegate: Row delegate handler, a valid callback required.
  • mixed $parameter: The object used to set the parameters in the SQL.
  • TList $result: An Ilist object used to hold the objects, pass in null if want to return a list instead.
  • int $skip: The number of rows to skip over.
  • int $max: The maximum number of rows to return.
registerTypeHandler (line 254)
  • access: public
void registerTypeHandler (TSqlMapTypeHandler $typeHandler)
update (line 226)

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).

  • return: The number of rows effected.
  • access: public
integer update (string $statementName, [mixed $parameter = null])
  • string $statementName: The name of the statement to execute.
  • mixed $parameter: The parameter 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()

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