Packages:
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:
Keyword

Class TSqlCriteria

TComponent
   |
   --TSqlCriteria

Direct Known Sub-classes:

Search criteria for TDbDataGateway.

Criteria object for data gateway finder methods. Usage:

  1. $criteria = new TSqlCriteria();
  2. $criteria->Parameters[':name'] = 'admin';
  3. $criteria->Parameters[':pass'] = 'prado';
  4. $criteria->OrdersBy['level'] = 'desc';
  5. $criteria->OrdersBy['name'] = 'asc';
  6. $criteria->Limit = 10;
  7. $criteria->Offset = 20;

Since: 3.1
Author: Wei Zhuo <weizho[at]gmail[dot]com>

Constructor Summary
public
__construct Array
Creates a new criteria with given condition;

Method Summary
string
boolean
int
int
TAttributeCollection
TAttributeCollection
mixed
Gets the field list to be placed after the SELECT in the SQL. Default to '*'
void
setCondition ( string $value)
Sets the search conditions to be placed after the WHERE clause in the SQL.
void
setLimit ( int $value)
void
setOffset ( int $value)
void
setOrdersBy ( mixed $value)
void
setParameters ( ArrayAccess $value)
void
setSelect ( mixed $value)
Sets the field list to be placed after the SELECT in the SQL.
string
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

Creates a new criteria with given condition;


Method Details

getCondition

public string getCondition ()

Output
string search conditions.
Exception

getIsNamedParameters

public boolean getIsNamedParameters ()

Output
boolean true if the parameter index are string base, false otherwise.
Exception

getLimit

public int getLimit ()

Output
int maximum number of records to return.
Exception

getOffset

public int getOffset ()

Output
int record offset.
Exception

getOrdersBy

public TAttributeCollection getOrdersBy ()

Output
TAttributeCollection ordering clause.
Exception

getParameters

public TAttributeCollection getParameters ()

Output
TAttributeCollection list of named parameters and values.
Exception

getSelect

public mixed getSelect ()

Gets the field list to be placed after the SELECT in the SQL. Default to '*'

Output
Exception

setCondition

public void setCondition (string $value )

Sets the search conditions to be placed after the WHERE clause in the SQL.

Input
string$valuesearch conditions.
Output
Exception

setLimit

public void setLimit (int $value )

Input
int$valuemaximum number of records to return.
Output
Exception

setOffset

public void setOffset (int $value )

Input
int$valuerecord offset.
Output
Exception

setOrdersBy

public void setOrdersBy (mixed $value )

Input
mixed$valueordering clause.
Output
Exception

setParameters

public void setParameters (ArrayAccess $value )

Input
ArrayAccess$valuenamed parameters.
Output
Exception

setSelect

public void setSelect (mixed $value )

Sets the field list to be placed after the SELECT in the SQL.

Different behavior depends on type of assigned value string usage without modification

null will be expanded to full list of quoted table column names (quoting depends on database)

array

  • Column names will be quoted if used as key or value of array
    1. array('col1', 'col2', 'col2')
    2. // SELECT `col1`, `col2`, `col3` FROM...
  • Column aliasing
    1. array('mycol1' => 'col1', 'mycol2' => 'COUNT(*)')
    2. // SELECT `col1` AS mycol1, COUNT(*) AS mycol2 FROM...
  • NULL and scalar values (strings will be quoted depending on database)
    1. array('col1' => 'my custom string', 'col2' => 1.0, 'col3' => 'NULL')
    2. // SELECT "my custom string" AS `col1`, 1.0 AS `col2`, NULL AS `col3` FROM...
  • If the *-wildcard char is used as key or value, add the full list of quoted table column names
    1. array('col1' => 'NULL', '*')
    2. // SELECT `col1`, `col2`, `col3`, NULL AS `col1` FROM...

Input
mixed$value
Output
Exception

__toString

public string __toString ()

Output
string string representation of the parameters. Useful for debugging.
Exception