$criteria = new TSqlCriteria();
$criteria->Parameters[':name'] = 'admin';
$criteria->Parameters[':pass'] = 'prado';
$criteria->OrdersBy['level'] = 'desc';
$criteria->OrdersBy['name'] = 'asc';
$criteria->Limit = 10;
$criteria->Offset = 20;
Show file
Open project: pradosoft/prado
Class Usage Examples
Method | Description | |
---|---|---|
__construct ( $condition = null, $parameters = [] ) | Creates a new criteria with given condition; | |
__toString ( ) : string | ||
getCondition ( ) : string | ||
getIsNamedParameters ( ) : boolean | ||
getLimit ( ) : integer | ||
getOffset ( ) : integer | ||
getOrdersBy ( ) : |
||
getParameters ( ) : |
||
getSelect ( ) : mixed | Gets the field list to be placed after the SELECT in the SQL. Default to '*' | |
setCondition ( $value ) | Sets the search conditions to be placed after the WHERE clause in the SQL. | |
setLimit ( $value ) | ||
setOffset ( $value ) | ||
setOrdersBy ( $value ) | ||
setParameters ( $value ) | ||
setSelect ( $value ) | Sets the field list to be placed after the SELECT in the SQL. |
public __construct ( $condition = null, $parameters = [] ) |
public __toString ( ) : string | ||
return | string | string representation of the parameters. Useful for debugging. |
public getIsNamedParameters ( ) : boolean | ||
return | boolean | true if the parameter index are string base, false otherwise. |
public getOrdersBy ( ) : |
||
return | ordering clause. |
public getParameters ( ) : |
||
return | list of named parameters and values. |
public setCondition ( $value ) |
array('col1', 'col2', 'col2')
SELECT col1, col2, col3 FROM...
- Column aliasing
array('mycol1' => 'col1', 'mycol2' => 'COUNT(*)')
SELECT col1 AS mycol1, COUNT(*) AS mycol2 FROM...
- NULL and scalar values (strings will be quoted depending on database)
array('col1' => 'my custom string', 'col2' => 1.0, 'col3' => 'NULL')
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
array('col1' => 'NULL', '*')
SELECT col1, col2, col3, NULL AS col1 FROM...
public setSelect ( $value ) |