Detailed Description

StringQuery executes queries from a string representation.

Queries are constructed in two possible ways:

  1. Like WHERE clauses in SQL
  2. As RQL queries (https://github.com/persvr/rql)

Note the following rules:

  • Foreign key relations between different types do not need to be included in the query string.
  • Attributes have to be prepended with the type name (or in case of ambiguity the role name), e.g. Author.name instead of name.
Note
: The query does not search in objects, that are created inside the current transaction.

The following example shows the usage:

$queryStr = "Author.name LIKE '%ingo%' AND (Recipe.name LIKE '%Salat%' OR Recipe.portions = 4)";
$query = new StringQuery('Author');
$query->setConditionString($queryStr);
$authorOIDs = $query->execute(false);
$queryStr = "(Profile.keyword1=in=8,1|Profile.keyword2=in=8,2|Profile.keywords3=in=8,3)&Profile.salary=gte=1000";
$query = new StringQuery('Profile');
$query->setConditionString($queryStr);
$authorOIDs = $query->execute(false);
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 53 of file StringQuery.php.

+ Inheritance diagram for StringQuery:

Public Member Functions

 getConditionString ()
 
 setConditionString ($condition)
 
 setRQLConditionString ($condition)
 
- Public Member Functions inherited from ObjectQuery
 __construct ($type, $queryId=SelectStatement::NO_CACHE)
 
 __destruct ()
 
 getId ()
 
 getObjectTemplate ($type, $alias=null, $combineOperator=Criteria::OPERATOR_AND)
 
 registerObjectTemplate (Node $template, $alias=null, $combineOperator=Criteria::OPERATOR_AND)
 
 makeGroup ($templates, $combineOperator=Criteria::OPERATOR_AND)
 
 getQueryCondition ()
 
 getQueryType ()
 
 valueChanged (ValueChangeEvent $event)
 
- Public Member Functions inherited from AbstractQuery
 execute ($buildDepth, $orderby=null, $pagingInfo=null)
 
 getQueryString ($buildDepth=BuildDepth::SINGLE, $orderby=null)
 
 getLastQueryString ()
 

Protected Member Functions

 buildQuery ($buildDepth, $orderby=null, PagingInfo $pagingInfo=null)
 
 parseRQL ($query)
 
- Protected Member Functions inherited from ObjectQuery
 getLogger ()
 
 processObjectTemplate (PersistentObject $tpl, SelectStatement $selectStmt)
 
 processOrderBy ($orderby, SelectStatement $selectStmt)
 
 getParameters ($criteria, array $parameters)
 
 getParameterPosition ($criterion, $criteria)
 
 resetInternals ()
 
 processTableName (Node $tpl)
 
- Protected Member Functions inherited from AbstractQuery
 executeInternal (SelectStatement $selectStmt, $buildDepth, PagingInfo $pagingInfo=null)
 

Static Protected Member Functions

static mapToDatabase ($type, $valueName)
 
- Static Protected Member Functions inherited from AbstractQuery
static getConnection ($type)
 
static getMapper ($type)
 

Additional Inherited Members

- Public Attributes inherited from ObjectQuery
const PROPERTY_COMBINE_OPERATOR = "object_query_combine_operator"
 
const PROPERTY_TABLE_NAME = "object_query_table_name"
 
const PROPERTY_INITIAL_OID = "object_query_initial_oid"
 

Member Function Documentation

◆ getConditionString()

getConditionString ( )

Get the query condition string.

Returns
String

Definition at line 61 of file StringQuery.php.

◆ setConditionString()

setConditionString (   $condition)

Set the query condition string.

Parameters
$conditionThe query definition string

Definition at line 69 of file StringQuery.php.

◆ setRQLConditionString()

setRQLConditionString (   $condition)

Set the query condition string as RQL.

Parameters
$conditionThe query definition string

Definition at line 77 of file StringQuery.php.

◆ buildQuery()

buildQuery (   $buildDepth,
  $orderby = null,
PagingInfo  $pagingInfo = null 
)
protected
See also
AbstractQuery::buildQuery()

Reimplemented from ObjectQuery.

Definition at line 84 of file StringQuery.php.

◆ parseRQL()

parseRQL (   $query)
protected

Parse the given query encoded in RQL (https://github.com/persvr/rql), e.g.

(Profile.keyword1=in=8,1|Profile.keyword2=in=8,2|Profile.keywords3=in=8,3)&Profile.yearlySalary=gte=1000

Parameters
$queryRQL query string
Returns
String

Definition at line 204 of file StringQuery.php.

◆ mapToDatabase()

static mapToDatabase (   $type,
  $valueName 
)
staticprotected

Map a application type and value name to the appropriate database names.

Parameters
$typeThe type to map
$valueNameThe name of the value to map
Returns
An array with the table and column name or null if no mapper is found

Definition at line 273 of file StringQuery.php.