TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 injectDataMapper (DataMapper $dataMapper)
 
 injectEnvironmentService (EnvironmentService $environmentService)
 
 __construct ()
 
 preparseQuery (QueryInterface $query)
 
 normalizeParameterIdentifier ($identifier)
 
 parseQuery (QueryInterface $query)
 
 addDynamicQueryParts (QuerySettingsInterface $querySettings, array &$sql)
 

Protected Member Functions

 preparseComparison ($comparison, $qomPath='')
 
 addNullConditionToStatementIfRequired (array $sql, $statement, $tableAlias)
 
 parseSource (Qom\SourceInterface $source, array &$sql)
 
 parseConstraint (Qom\ConstraintInterface $constraint=null, Qom\SourceInterface $source, array &$sql)
 
 parseOrderings (array $orderings, Qom\SourceInterface $source, array &$sql)
 
 parseComparison (Qom\ComparisonInterface $comparison, Qom\SourceInterface $source, array &$sql)
 
 parseDynamicOperand (Qom\ComparisonInterface $comparison, Qom\SourceInterface $source, array &$sql)
 
 parseOperand (Qom\DynamicOperandInterface $operand, Qom\SourceInterface $source, array &$sql)
 
 addRecordTypeConstraint ($className, &$sql)
 
 getAdditionalMatchFieldsStatement ($columnMap, $childTableName, $childTableAlias, $parentTable=null)
 
 getAdditionalWhereClause (QuerySettingsInterface $querySettings, $tableName, $tableAlias=null)
 
 getVisibilityConstraintStatement (QuerySettingsInterface $querySettings, $tableName, $tableAlias)
 
 getFrontendConstraintStatement ($tableName, $ignoreEnableFields, array $enableFieldsToBeIgnored=[], $includeDeleted)
 
 getBackendConstraintStatement ($tableName, $ignoreEnableFields, $includeDeleted)
 
 getSysLanguageStatement ($tableName, $tableAlias, $querySettings)
 
 getPageIdStatement ($tableName, $tableAlias, array $storagePageIds)
 
 parseJoin (Qom\JoinInterface $join, array &$sql)
 
 getUniqueAlias (array &$sql, $tableName, $fullPropertyPath=null)
 
 addUnionStatement (&$className, &$tableName, &$propertyPath, array &$sql, &$fullPropertyPath)
 
 replaceTableNameWithAlias ($statement, $tableName, $tableAlias)
 
 resolveOperator ($operator)
 
 getPageRepository ()
 
 getTSFE ()
 

Protected Attributes

 $databaseHandle
 
 $dataMapper
 
 $pageRepository
 
 $environmentService
 
 $tablePropertyMap = []
 

Detailed Description

QueryParser, converting the qom to string representation

Definition at line 36 of file Typo3DbQueryParser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::__construct ( )

Constructor. takes the database handle from $GLOBALS['TYPO3_DB']

Definition at line 91 of file Typo3DbQueryParser.php.

References $GLOBALS.

Member Function Documentation

◆ addDynamicQueryParts()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::addDynamicQueryParts ( QuerySettingsInterface  $querySettings,
array &  $sql 
)

Add query parts that MUST NOT be cached. Call this function for any query

Parameters
QuerySettingsInterface$querySettings
array$sql
Exceptions

Definition at line 243 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addNullConditionToStatementIfRequired(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ addNullConditionToStatementIfRequired()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::addNullConditionToStatementIfRequired ( array  $sql,
  $statement,
  $tableAlias 
)
protected

If the given table alias is used in a UNION statement it is required to add an additional condition that allows the fields of the joined table to be NULL. Otherwise the condition would be too strict and filter out records that are actually valid.

Parameters
array$sqlThe current SQL query parts.
string$statementThe SQL statement to which the NULL condition should be added.
string$tableAliasThe table alias used in the SQL statement.
Returns
string The statement including the NULL condition or the original statement.

Definition at line 268 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addDynamicQueryParts(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseQuery().

◆ addRecordTypeConstraint()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::addRecordTypeConstraint (   $className,
$sql 
)
protected

Add a constraint to ensure that the record type of the returned tuples is matching the data type of the repository.

Parameters
string$classNameThe class name
array&$sqlThe query parts
Returns
void

Definition at line 508 of file Typo3DbQueryParser.php.

References $sql.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseJoin(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseSource().

◆ addUnionStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::addUnionStatement ( $className,
$tableName,
$propertyPath,
array &  $sql,
$fullPropertyPath 
)
protected

adds a union statement to the query, mostly for tables referenced in the where condition. The property for which the union statement is generated will be appended.

Parameters
string&$classNameThe name of the parent class, will be set to the child class after processing.
string&$tableNameThe name of the parent table, will be set to the table alias that is used in the union statement.
string&$propertyPathThe remaining property path, will be cut of by one part during the process.
array&$sqlThe SQL statement parts, will be filled with the union statements.
string$fullPropertyPathThe full path the the current property, will be used to make table names unique.
Exceptions
Exception
Exception

Definition at line 849 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalMatchFieldsStatement(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getUniqueAlias(), TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_AND_BELONGS_TO_MANY, TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_MANY, and TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_ONE.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseOperand(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseOrderings().

◆ getAdditionalMatchFieldsStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getAdditionalMatchFieldsStatement (   $columnMap,
  $childTableName,
  $childTableAlias,
  $parentTable = null 
)
protected

Builds a condition for filtering records by the configured match field, e.g. MM_match_fields, foreign_match_fields or foreign_table_field.

Parameters
ColumnMap$columnMapThe column man for which the condition should be build.
string$childTableNameThe real name of the child record table.
string$childTableAliasThe alias of the child record table used in the query.
string$parentTableThe real name of the parent table (used for building the foreign_table_field condition).
Returns
string The match field conditions or an empty string.

Definition at line 545 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison().

◆ getAdditionalWhereClause()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getAdditionalWhereClause ( QuerySettingsInterface  $querySettings,
  $tableName,
  $tableAlias = null 
)
protected

◆ getBackendConstraintStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getBackendConstraintStatement (   $tableName,
  $ignoreEnableFields,
  $includeDeleted 
)
protected

Returns constraint statement for backend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string

Definition at line 664 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\BEenableFields(), and TYPO3\CMS\Backend\Utility\BackendUtility\deleteClause().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ getFrontendConstraintStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getFrontendConstraintStatement (   $tableName,
  $ignoreEnableFields,
array  $enableFieldsToBeIgnored = [],
  $includeDeleted 
)
protected

Returns constraint statement for frontend context

Parameters
string$tableName
bool$ignoreEnableFieldsA flag indicating whether the enable fields should be ignored
array$enableFieldsToBeIgnoredIf $ignoreEnableFields is true, this array specifies enable fields to be ignored. If it is NULL or an empty array (default) all enable fields are ignored.
bool$includeDeletedA flag indicating whether deleted records should be included
Returns
string
Exceptions
InconsistentQuerySettingsException

Definition at line 638 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getPageRepository().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ getPageIdStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getPageIdStatement (   $tableName,
  $tableAlias,
array  $storagePageIds 
)
protected

Builds the page ID checking statement

Parameters
string$tableNameThe database table name
string$tableAliasThe table alias used in the query.
array$storagePageIdslist of storage page ids
Exceptions
InconsistentQuerySettingsException
Returns
string

Definition at line 735 of file Typo3DbQueryParser.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalWhereClause().

◆ getPageRepository()

◆ getSysLanguageStatement()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getSysLanguageStatement (   $tableName,
  $tableAlias,
  $querySettings 
)
protected

Builds the language field statement

Parameters
string$tableNameThe database table name
string$tableAliasThe table alias used in the query.
QuerySettingsInterface$querySettingsThe TYPO3 CMS specific query settings
Returns
string

Definition at line 684 of file Typo3DbQueryParser.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getAdditionalWhereClause().

◆ getTSFE()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getTSFE ( )
protected
Returns
TypoScriptFrontendController|null

Definition at line 994 of file Typo3DbQueryParser.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getPageRepository().

◆ getUniqueAlias()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::getUniqueAlias ( array &  $sql,
  $tableName,
  $fullPropertyPath = null 
)
protected

Generates a unique alias for the given table and the given property path. The property path will be mapped to the generated alias in the tablePropertyMap.

Parameters
array$sqlThe SQL satement parts, will be filled with the tableAliasMap.
string$tableNameThe name of the table for which the alias should be generated.
string$fullPropertyPathThe full property path that is related to the given table.
Returns
string The generated table alias.

Definition at line 814 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseJoin(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseSource().

◆ getVisibilityConstraintStatement()

◆ injectDataMapper()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::injectDataMapper ( DataMapper  $dataMapper)
Parameters
DataMapper$dataMapper

Definition at line 65 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$dataMapper.

◆ injectEnvironmentService()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::injectEnvironmentService ( EnvironmentService  $environmentService)
Parameters
EnvironmentService$environmentService

Definition at line 73 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\$environmentService.

◆ normalizeParameterIdentifier()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::normalizeParameterIdentifier (   $identifier)

◆ parseComparison()

◆ parseConstraint()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseConstraint ( Qom\ConstraintInterface  $constraint = null,
Qom\SourceInterface  $source,
array &  $sql 
)
protected

Transforms a constraint into SQL and parameter arrays

Parameters
Qom\ConstraintInterface$constraintThe constraint
Qom\SourceInterface$sourceThe source
array&$sqlThe query parts
Returns
void

Definition at line 306 of file Typo3DbQueryParser.php.

References $sql, and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseQuery().

◆ parseDynamicOperand()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseDynamicOperand ( Qom\ComparisonInterface  $comparison,
Qom\SourceInterface  $source,
array &  $sql 
)
protected

Parse a DynamicOperand into SQL and parameter arrays.

Parameters
Qom\ComparisonInterface$comparison
Qom\SourceInterface$sourceThe source
array&$sqlThe query parts
Returns
void

Definition at line 450 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\normalizeParameterIdentifier(), TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseOperand(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\resolveOperator().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseComparison().

◆ parseJoin()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseJoin ( Qom\JoinInterface  $join,
array &  $sql 
)
protected

Transforms a Join into SQL and parameter arrays

Parameters
Qom\JoinInterface$joinThe join
array&$sqlThe query parts
Returns
void

Definition at line 773 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addRecordTypeConstraint(), and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getUniqueAlias().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseSource().

◆ parseOperand()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseOperand ( Qom\DynamicOperandInterface  $operand,
Qom\SourceInterface  $source,
array &  $sql 
)
protected
Parameters
Qom\DynamicOperandInterface$operand
Qom\SourceInterface$sourceThe source
array&$sqlThe query parts
Returns
string
Exceptions

Definition at line 473 of file Typo3DbQueryParser.php.

References $sql, and TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement().

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseDynamicOperand().

◆ parseOrderings()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseOrderings ( array  $orderings,
Qom\SourceInterface  $source,
array &  $sql 
)
protected

Transforms orderings into SQL.

Parameters
array$orderingsAn array of orderings (Qom)
Qom\SourceInterface$sourceThe source
array&$sqlThe query parts
Returns
void
Exceptions
UnsupportedOrderException

Definition at line 338 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\addUnionStatement(), TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_ASCENDING, and TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_DESCENDING.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\parseQuery().

◆ parseQuery()

◆ parseSource()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::parseSource ( Qom\SourceInterface  $source,
array &  $sql 
)
protected

◆ preparseComparison()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::preparseComparison (   $comparison,
  $qomPath = '' 
)
protected

Walks through the qom's constraints and extracts the properties and values.

In the qom the query structure and values are glued together. This walks through the qom and only extracts the parts necessary for generating the hash and filling the statement. It leaves out the actual statement generation, as it is the most time consuming.

Parameters
Qom\ConstraintInterface$comparisonThe constraint. Could be And-, Or-, Not- or ComparisonInterface
string$qomPathcurrent position of the child in the qom
Returns
array Array of parameters and operators
Exceptions

Definition at line 130 of file Typo3DbQueryParser.php.

References TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\normalizeParameterIdentifier(), and TYPO3\CMS\Extbase\Persistence\QueryInterface\OPERATOR_IN.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\preparseQuery().

◆ preparseQuery()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::preparseQuery ( QueryInterface  $query)

◆ replaceTableNameWithAlias()

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::replaceTableNameWithAlias (   $statement,
  $tableName,
  $tableAlias 
)
protected

If the table name does not match the table alias all occurrences of "tableName." are replaced with "tableAlias." in the given SQL statement.

Parameters
string$statementThe SQL statement in which the values are replaced.
string$tableNameThe table name that is replaced.
string$tableAliasThe table alias that replaced the table name.
Returns
string The modified SQL statement.

Definition at line 920 of file Typo3DbQueryParser.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser\getVisibilityConstraintStatement().

◆ resolveOperator()

Member Data Documentation

◆ $databaseHandle

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$databaseHandle
protected

Definition at line 43 of file Typo3DbQueryParser.php.

◆ $dataMapper

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$dataMapper
protected

◆ $environmentService

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$environmentService
protected

◆ $pageRepository

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$pageRepository
protected

◆ $tablePropertyMap

TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::$tablePropertyMap = []
protected

Definition at line 86 of file Typo3DbQueryParser.php.