- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml
Classes:
TInvalidPropertyException
TLazyLoadList
TObjectProxy
TPropertyAccess
TSqlMapApplicationCache
TSqlMapCache
TSqlMapConfig
TSqlMapConfigurationException
TSqlMapDuplicateException
TSqlMapException
TSqlMapExecutionException
TSqlMapFifoCache
TSqlMapGateway
TSqlMapLruCache
TSqlMapManager
TSqlMapPagedList
TSqlMapTypeHandler
TSqlMapTypeHandlerRegistry
TSqlMapUndefinedException

Keyword

# Class TSqlMapGateway

    TComponent
       |
       --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.
Since: 3.1
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>

Constructor Summary
public | __construct Array

Method Summary
integer | delete ( string $statementName, mixed $parameter) Executes a Sql DELETE statement. Delete returns the number of rows effected.
void | flushCaches () Flushes all cached objects that belong to this SqlMap
TDbConnection | getDbConnection ()
TSqlMapManager | getSqlMapManager ()
mixed | insert ( string $statementName, string $parameter) Executes a Sql INSERT statement.
TList | queryForList ( string $statementName, mixed $parameter, TList $result, int $skip, int $max) Executes a Sql SELECT statement that returns data to populate a number of result objects.
TMap | queryForMap ( string $statementName, mixed $parameter, string $keyProperty, string $valueProperty, mixed $skip, mixed $max) Executes the SQL and retuns all rows selected in a map that is keyed on
TMap | queryForMapWithRowDelegate ( string $statementName, callback $delegate, mixed $parameter, string $keyProperty, string $valueProperty, mixed $skip, mixed $max) Runs a query with a custom object that gets a chance to deal with each row as it is processed.
object A | queryForObject ( string $statementName, mixed $parameter, mixed $result) Executes a Sql SELECT statement that returns that returns data to populate a single object instance.
TPagedList | queryForPagedList ( string $statementName, mixed $parameter, integer $pageSize, integer $page) 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.
TPagedList | queryForPagedListWithRowDelegate ( string $statementName, callback $delegate, mixed $parameter, integer $pageSize, integer $page) 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.
TList | queryWithRowDelegate ( string $statementName, callback $delegate, mixed $parameter, TList $result, int $skip, int $max) Runs a query for list with a custom object that gets a chance to deal with each row as it is processed.
void | registerTypeHandler ( TSqlMapTypeHandler $typeHandler)
integer | update ( string $statementName, mixed $parameter) Executes a Sql UPDATE statement.

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

Constructor Details

## __construct

public __construct | Array

Method Details

## delete

public integer delete | (string $statementName , mixed $parameter )

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

Input
string | $statementName | The name of the statement to execute.
mixed | $parameter | The parameter object.
Output
integer | The number of rows effected.
Exception

## flushCaches

public void flushCaches | ()

Flushes all cached objects that belong to this SqlMap

Output
Exception

## getDbConnection

public TDbConnection getDbConnection | ()

Output
TDbConnection | database connection.
Exception

## getSqlMapManager

public TSqlMapManager getSqlMapManager | ()

Output
TSqlMapManager | sqlmap manager.
Exception

## insert

public mixed insert | (string $statementName , string $parameter )

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.

Input
string | $statementName | The name of the statement to execute.
string | $parameter | The parameter object.
Output
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.
Exception

## queryForList

public TList queryForList | (string $statementName , mixed $parameter , TList $result , int $skip , int $max )

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.

Input
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.
Output
TList | A List of result objects.
Exception

## queryForMap

public TMap queryForMap | (string $statementName , mixed $parameter , string $keyProperty , string $valueProperty , mixed $skip , mixed $max )

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.

Input
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.
mixed | $skip |
mixed | $max |
Output
TMap | Array object containing the rows keyed by keyProperty.
Exception

## queryForMapWithRowDelegate

public TMap queryForMapWithRowDelegate | (string $statementName , callback $delegate , mixed $parameter , string $keyProperty , string $valueProperty , mixed $skip , mixed $max )

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

Input
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.
mixed | $skip |
mixed | $max |
Output
TMap | Array object containing the rows keyed by keyProperty.
Exception

## queryForObject

public object A queryForObject | (string $statementName , mixed $parameter , mixed $result )

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.

Input
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.
Output
object A | single result object populated with the result set data.
Exception

## queryForPagedList

public TPagedList queryForPagedList | (string $statementName , mixed $parameter , integer $pageSize , integer $page )

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.

Input
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.
integer | $page | The number of the page to initially load into the list.
Output
TPagedList | A PaginatedList of beans containing the rows.
Exception

## queryForPagedListWithRowDelegate

public TPagedList queryForPagedListWithRowDelegate | (string $statementName , callback $delegate , mixed $parameter , integer $pageSize , integer $page )

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

Input
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.
integer | $page | The number of the page to initially load into the list.
Output
TPagedList | A PaginatedList of beans containing the rows.
Exception

## queryWithRowDelegate

public TList queryWithRowDelegate | (string $statementName , callback $delegate , mixed $parameter , TList $result , int $skip , int $max )

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

Input
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.
Output
TList | A List of result objects.
Exception

## registerTypeHandler

public void registerTypeHandler | (TSqlMapTypeHandler $typeHandler )

Input
TSqlMapTypeHandler | $typeHandler | new type handler.
Output
Exception

## update

public integer update | (string $statementName , mixed $parameter )

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

Input
string | $statementName | The name of the statement to execute.
mixed | $parameter | The parameter object.
Output
integer | The number of rows effected.
Exception