Class ConditionParser
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Creates from a custom condition syntax a sql condition
The user can write a condition in a special syntax. This class will parse that condition and creates a valid SQL statement which can be used in another SQL statement to select data with these conditions. This class uses AdmExceptions when an error occurred. Make sure you catch these exceptions when using the class.
Class: ConditionParser
Code:
// create a valid SQL condition out of the special syntax $parser = new ConditionParser; $sqlCondition = $parser->makeSqlStatement('> 5 AND <= 100', 'usd_value', 'int'); $sql = 'SELECT * FROM '.TBL_USER_DATA.' WHERE usd_id > 0 AND '.$sqlCondition; @endcode
Par: Examples
Located at conditionparser.php
Methods summary
private
string
|
#
getFormatDate( string $date, string $operator )
Creates a valid date format @b YYYY-MM-DD for the SQL statement |
public
string
|
#
makeStandardCondition( string $sourceCondition )
Replace different user conditions with predefined chars that represents a special condition e.g. @b ! represents @b != and @b <> |
public
string
|
#
makeSqlStatement( string $sourceCondition, string $columnName, string $columnType, string $fieldName )
Creates from a user defined condition a valid SQL condition |
public
|
#
setNotExistsStatement( string $sqlStatement )
Stores an sql statement that checks if a record in a table does exists or not exists. This must bei a full subselect that starts with SELECT. The statement is used if a condition with EMPTY or NOT EMPTY is used. |
Properties summary
private
|
$mSrcCond
|
|
private
|
$mDestCond
|
|
private
|
$mSrcCondArray
|
|
private
string
|
$mNotExistsSql
|
#
''
|
private
boolean
|
$mOpenQuotes
|
#
false
|