PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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
Extended by TSqlMapGateway
Package: System\Data\SqlMap
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo <weizhuo[at]gmail[dot]com>
Since: 3.1
Located at Data/SqlMap/TSqlMapGateway.php
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

TComponent::__construct()
public TSqlMapManager
# getSqlMapManager( )

Returns

TSqlMapManager
sqlmap manager.
public TDbConnection
# getDbConnection( )

Returns

TDbConnection
database connection.
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
# registerTypeHandler( TSqlMapTypeHandler $typeHandler )

Parameters

$typeHandler
TSqlMapTypeHandler
new type handler.
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()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO