Typo3DbQueryParser
QueryParser, converting the qom to string representation
only to be used within Extbase, not part of TYPO3 Core API.
Attributes
- #[Autoconfigure]
- $public: true
- $shared: false
Table of Contents
Properties
- $dataMapper : DataMapper
- $pageRepository : PageRepository
- The TYPO3 page repository. Used for language and workspace overlay
- $queryBuilder : QueryBuilder
- Instance of the Doctrine query builder
- $suggestDistinctQuery : bool
- $tableAliasMap : array<string, string>
- Maps tablenames to their aliases to be used in where clauses etc.
- $tableName : string
- $tablePropertyMap : array<string|int, mixed>
- Maps domain model properties to their corresponding table aliases that are used in the query, e.g.:
- $unionTableAliasCache : array<string|int, mixed>
- Stores all tables used in for SQL joins
Methods
- __construct() : mixed
- convertQueryToDoctrineQueryBuilder() : QueryBuilder
- Returns a ready to be executed QueryBuilder object, based on the query
- isDistinctQuerySuggested() : bool
- Whether using a distinct query is suggested.
- addRecordTypeConstraint() : mixed
- Add a constraint to ensure that the record type of the returned tuples is matching the data type of the repository.
- addTypo3Constraints() : mixed
- add TYPO3 Constraints for all tables to the queryBuilder
- addUnionStatement() : mixed
- adds a union statement to the query, mostly for tables referenced in the where condition.
- createTypedNamedParameter() : string
- Create a named parameter for the QueryBuilder and guess the parameter type based on the output of DataMapper::getPlainValue(). The type of the named parameter can be forced to one of the \PDO::PARAM_* types by specifying the $forceType argument.
- getAdditionalMatchFieldsStatement() : CompositeExpression|string
- Builds a condition for filtering records by the configured match field, e.g. MM_match_fields, foreign_match_fields or foreign_table_field.
- getAdditionalWhereClause() : array<string|int, mixed>
- Adds additional WHERE statements according to the query settings.
- getBackendConstraintStatement() : string
- Returns constraint statement for backend context
- getFrontendConstraintStatement() : string
- Returns constraint statement for frontend context
- getLanguageStatement() : CompositeExpression|string
- Builds the language field statement
- getPageIdStatement() : string
- Builds the page ID checking statement
- getPageRepository() : PageRepository
- getParameterType() : ParameterType
- Maps plain value of operand to PDO types to help Doctrine and/or the database driver process the value correctly when building the query.
- getUniqueAlias() : string
- Generates a unique alias for the given table and the given property path.
- getVisibilityConstraintStatement() : string
- Adds enableFields and deletedClause to the query if necessary
- initializeQueryBuilder() : void
- Creates the queryBuilder object whether it is a regular select or a JOIN
- parseComparison() : string
- Parse a Comparison into SQL and parameter arrays.
- parseConstraint() : CompositeExpression|string
- Transforms a constraint into SQL and parameter arrays
- parseDynamicOperand() : string
- Parse a DynamicOperand into SQL and parameter arrays.
- parseJoin() : void
- Transforms a Join into SQL and parameter arrays
- parseOperand() : string
- parseOrderings() : void
- Transforms orderings into SQL.
- replaceTableNameWithAlias() : string
- If the table name does not match the table alias all occurrences of "tableName." are replaced with "tableAlias." in the given SQL statement.
Properties
$dataMapper
protected
DataMapper
$dataMapper
$pageRepository
The TYPO3 page repository. Used for language and workspace overlay
protected
PageRepository
$pageRepository
$queryBuilder
Instance of the Doctrine query builder
protected
QueryBuilder
$queryBuilder
$suggestDistinctQuery
protected
bool
$suggestDistinctQuery
= false
$tableAliasMap
Maps tablenames to their aliases to be used in where clauses etc.
protected
array<string, string>
$tableAliasMap
= []
Mainly used for joins on the same table etc.
$tableName
protected
string
$tableName
= ''
$tablePropertyMap
Maps domain model properties to their corresponding table aliases that are used in the query, e.g.:
protected
array<string|int, mixed>
$tablePropertyMap
= []
'property1' => 'tableName', 'property1.property2' => 'tableName1',
$unionTableAliasCache
Stores all tables used in for SQL joins
protected
array<string|int, mixed>
$unionTableAliasCache
= []
Methods
__construct()
public
__construct(DataMapper $dataMapper) : mixed
Parameters
- $dataMapper : DataMapper
convertQueryToDoctrineQueryBuilder()
Returns a ready to be executed QueryBuilder object, based on the query
public
convertQueryToDoctrineQueryBuilder(QueryInterface $query) : QueryBuilder
Parameters
- $query : QueryInterface
Return values
QueryBuilderisDistinctQuerySuggested()
Whether using a distinct query is suggested.
public
isDistinctQuerySuggested() : bool
This information is defined during parsing of the current query for RELATION_HAS_MANY & RELATION_HAS_AND_BELONGS_TO_MANY relations.
Return values
booladdRecordTypeConstraint()
Add a constraint to ensure that the record type of the returned tuples is matching the data type of the repository.
protected
addRecordTypeConstraint(string $className) : mixed
Parameters
- $className : string
-
The class name
addTypo3Constraints()
add TYPO3 Constraints for all tables to the queryBuilder
protected
addTypo3Constraints(QueryInterface $query) : mixed
Parameters
- $query : QueryInterface
addUnionStatement()
adds a union statement to the query, mostly for tables referenced in the where condition.
protected
addUnionStatement(string &$className, string &$tableName, string &$propertyPath, string &$fullPropertyPath) : mixed
The property for which the union statement is generated will be appended.
Parameters
- $className : string
-
The name of the parent class, will be set to the child class after processing.
- $tableName : string
-
The name of the parent table, will be set to the table alias that is used in the union statement.
- $propertyPath : string
-
The remaining property path, will be cut of by one part during the process.
- $fullPropertyPath : string
-
The full path the current property, will be used to make table names unique.
Tags
createTypedNamedParameter()
Create a named parameter for the QueryBuilder and guess the parameter type based on the output of DataMapper::getPlainValue(). The type of the named parameter can be forced to one of the \PDO::PARAM_* types by specifying the $forceType argument.
protected
createTypedNamedParameter(mixed $value[, ParameterType|Type|ArrayParameterType|null $forceType = null ]) : string
Parameters
- $value : mixed
-
The input value that should be sent to the database
- $forceType : ParameterType|Type|ArrayParameterType|null = null
-
The \TYPO3\CMS\Core\Database\Connection::PARAM_* type that should be forced
Tags
Return values
string —The placeholder string to be used in the query
getAdditionalMatchFieldsStatement()
Builds a condition for filtering records by the configured match field, e.g. MM_match_fields, foreign_match_fields or foreign_table_field.
protected
getAdditionalMatchFieldsStatement(ExpressionBuilder $exprBuilder, ColumnMap $columnMap, string $childTableAlias[, string $parentTable = null ]) : CompositeExpression|string
Parameters
- $exprBuilder : ExpressionBuilder
- $columnMap : ColumnMap
-
The column man for which the condition should be build.
- $childTableAlias : string
-
The alias of the child record table used in the query.
- $parentTable : string = null
-
The real name of the parent table (used for building the foreign_table_field condition).
Return values
CompositeExpression|string —The match field conditions or an empty string.
getAdditionalWhereClause()
Adds additional WHERE statements according to the query settings.
protected
getAdditionalWhereClause(QuerySettingsInterface $querySettings, string $tableName[, string $tableAlias = null ]) : array<string|int, mixed>
Parameters
- $querySettings : QuerySettingsInterface
-
The TYPO3 CMS specific query settings
- $tableName : string
-
The table name to add the additional where clause for
- $tableAlias : string = null
-
The table alias used in the query.
Return values
array<string|int, mixed>getBackendConstraintStatement()
Returns constraint statement for backend context
protected
getBackendConstraintStatement(string $tableName, bool $ignoreEnableFields, bool $includeDeleted) : string
Parameters
- $tableName : string
- $ignoreEnableFields : bool
-
A flag indicating whether the enable fields should be ignored
- $includeDeleted : bool
-
A flag indicating whether deleted records should be included
Return values
stringgetFrontendConstraintStatement()
Returns constraint statement for frontend context
protected
getFrontendConstraintStatement(string $tableName, string $tableAlias, bool $ignoreEnableFields, array<string|int, mixed> $enableFieldsToBeIgnored, bool $includeDeleted) : string
Parameters
- $tableName : string
- $tableAlias : string
- $ignoreEnableFields : bool
-
A flag indicating whether the enable fields should be ignored
- $enableFieldsToBeIgnored : array<string|int, mixed>
-
If $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.
- $includeDeleted : bool
-
A flag indicating whether deleted records should be included
Tags
Return values
stringgetLanguageStatement()
Builds the language field statement
protected
getLanguageStatement(string $tableName, string $tableAlias, QuerySettingsInterface $querySettings) : CompositeExpression|string
Parameters
- $tableName : string
-
The database table name
- $tableAlias : string
-
The table alias used in the query.
- $querySettings : QuerySettingsInterface
-
The TYPO3 CMS specific query settings
Return values
CompositeExpression|stringgetPageIdStatement()
Builds the page ID checking statement
protected
getPageIdStatement(string $tableName, string $tableAlias, array<string|int, mixed> $storagePageIds) : string
Parameters
- $tableName : string
-
The database table name
- $tableAlias : string
-
The table alias used in the query.
- $storagePageIds : array<string|int, mixed>
-
list of storage page ids
Tags
Return values
stringgetPageRepository()
protected
getPageRepository() : PageRepository
Return values
PageRepositorygetParameterType()
Maps plain value of operand to PDO types to help Doctrine and/or the database driver process the value correctly when building the query.
protected
getParameterType(mixed $value) : ParameterType
Parameters
- $value : mixed
Return values
ParameterTypegetUniqueAlias()
Generates a unique alias for the given table and the given property path.
protected
getUniqueAlias(string $tableName[, string $fullPropertyPath = null ]) : string
The property path will be mapped to the generated alias in the tablePropertyMap.
Parameters
- $tableName : string
-
The name of the table for which the alias should be generated.
- $fullPropertyPath : string = null
-
The full property path that is related to the given table.
Return values
string —The generated table alias.
getVisibilityConstraintStatement()
Adds enableFields and deletedClause to the query if necessary
protected
getVisibilityConstraintStatement(QuerySettingsInterface $querySettings, string $tableName, string $tableAlias) : string
Parameters
- $querySettings : QuerySettingsInterface
- $tableName : string
-
The database table name
- $tableAlias : string
Return values
stringinitializeQueryBuilder()
Creates the queryBuilder object whether it is a regular select or a JOIN
protected
initializeQueryBuilder(SourceInterface $source) : void
Parameters
- $source : SourceInterface
parseComparison()
Parse a Comparison into SQL and parameter arrays.
protected
parseComparison(ComparisonInterface $comparison, SourceInterface $source) : string
Parameters
- $comparison : ComparisonInterface
- $source : SourceInterface
Tags
Return values
stringparseConstraint()
Transforms a constraint into SQL and parameter arrays
protected
parseConstraint(ConstraintInterface $constraint, SourceInterface $source) : CompositeExpression|string
Parameters
- $constraint : ConstraintInterface
- $source : SourceInterface
Return values
CompositeExpression|stringparseDynamicOperand()
Parse a DynamicOperand into SQL and parameter arrays.
protected
parseDynamicOperand(ComparisonInterface $comparison, SourceInterface $source) : string
Parameters
- $comparison : ComparisonInterface
- $source : SourceInterface
Tags
Return values
stringparseJoin()
Transforms a Join into SQL and parameter arrays
protected
parseJoin(JoinInterface $join, string $leftTableAlias) : void
Parameters
- $join : JoinInterface
- $leftTableAlias : string
parseOperand()
protected
parseOperand(DynamicOperandInterface $operand, SourceInterface $source) : string
Parameters
- $operand : DynamicOperandInterface
- $source : SourceInterface
Return values
stringparseOrderings()
Transforms orderings into SQL.
protected
parseOrderings(array<string|int, mixed> $orderings, SourceInterface $source) : void
Parameters
- $orderings : array<string|int, mixed>
-
An array of orderings (Qom\Ordering)
- $source : SourceInterface
Tags
replaceTableNameWithAlias()
If the table name does not match the table alias all occurrences of "tableName." are replaced with "tableAlias." in the given SQL statement.
protected
replaceTableNameWithAlias(string $statement, string $tableName, string $tableAlias) : string
Parameters
- $statement : string
-
The SQL statement in which the values are replaced.
- $tableName : string
-
The table name that is replaced.
- $tableAlias : string
-
The table alias that replaced the table name.
Return values
string —The modified SQL statement.