Typo3DbQueryParser
class \
QueryParser, converting the qom to string representation
Internal
only to be used within Extbase, not part of TYPO3 Core API.
Attributes
- #[Autoconfigure]
- $public: true
- $shared: false
Table of Contents
Properties
- $connectionPool : ConnectionPool
- $dataMapper : DataMapper
- $queryBuilder : QueryBuilder|null
- $querySettings : QuerySettingsInterface|null
- $suggestDistinctQuery : bool
- $tableAliasMap : array<string, string>
- Maps tablenames to their aliases to be used in where clauses etc.
- $tablePropertyMap : array
- Maps domain model properties to their corresponding table aliases that are used in the query, e.g.:
- $tcaSchemaFactory : TcaSchemaFactory
- $unionTableAliasCache : array
- 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() : void
- Add a constraint to ensure that the record type of the returned tuples is matching the data type of the repository.
- addTypo3Constraints() : void
- 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
- 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
- getJoinVisibilityConstraintStatement() : string
- Visibility constraints of a joined table belong into the join condition. Otherwise, a parent record with only invisible children would be removed from the result, as the joined rows of these children do not fulfill the visibility constraints in the WHERE clause.
- getLanguageStatement() : CompositeExpression|string
- Builds the language field statement
- getPageIdStatement() : string
- Builds the page ID checking statement
- 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.
- parseFunctionExpression() : string
- Parses a function expression (CONCAT, TRIM, COALESCE) into SQL.
- 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
$connectionPool read-only
protected
ConnectionPool
$connectionPool
$dataMapper read-only
protected
DataMapper
$dataMapper
$queryBuilder
protected
QueryBuilder|null
$queryBuilder
= null
$querySettings
protected
QuerySettingsInterface|null
$querySettings
= null
$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.
$tablePropertyMap
Maps domain model properties to their corresponding table aliases that are used in the query, e.g.:
protected
array
$tablePropertyMap
= []
'property1' => 'tableName', 'property1.property2' => 'tableName1',
$tcaSchemaFactory read-only
protected
TcaSchemaFactory
$tcaSchemaFactory
$unionTableAliasCache
Stores all tables used in for SQL joins
protected
array
$unionTableAliasCache
= []
Methods
__construct()
public
__construct(DataMapper $dataMapper, TcaSchemaFactory $tcaSchemaFactory, ConnectionPool $connectionPool) : mixed
Parameters
- $dataMapper : DataMapper
- $tcaSchemaFactory : TcaSchemaFactory
- $connectionPool : ConnectionPool
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|null $className) : void
Parameters
- $className : string|null
-
The class name
addTypo3Constraints()
add TYPO3 Constraints for all tables to the queryBuilder
protected
addTypo3Constraints(QueryInterface $query) : void
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 ][, ColumnMap|null $columnMap = 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
- $columnMap : ColumnMap|null = null
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) : array
Parameters
- $querySettings : QuerySettingsInterface
-
The TYPO3 CMS specific query settings
- $tableName : string
-
The table name to add the additional where clause for
- $tableAlias : string
-
The table alias used in the query.
Return values
arraygetBackendConstraintStatement()
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 $enableFieldsToBeIgnored, bool $includeDeleted) : string
Parameters
- $tableName : string
- $tableAlias : string
- $ignoreEnableFields : bool
-
A flag indicating whether the enable fields should be ignored
- $enableFieldsToBeIgnored : array
-
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
stringgetJoinVisibilityConstraintStatement()
Visibility constraints of a joined table belong into the join condition. Otherwise, a parent record with only invisible children would be removed from the result, as the joined rows of these children do not fulfill the visibility constraints in the WHERE clause.
protected
getJoinVisibilityConstraintStatement(string $tableName, string $tableAlias) : string
Parameters
- $tableName : string
- $tableAlias : string
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 $storagePageIds) : string
Parameters
- $tableName : string
-
The database table name
- $tableAlias : string
-
The table alias used in the query.
- $storagePageIds : array
-
list of storage page ids
Tags
Return values
stringgetParameterType()
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|null $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 = 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
- $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
stringparseFunctionExpression()
Parses a function expression (CONCAT, TRIM, COALESCE) into SQL.
protected
parseFunctionExpression(FunctionExpressionInterface $expression, SourceInterface $source) : string
Parameters
- $expression : FunctionExpressionInterface
- $source : SourceInterface
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[, ColumnMap|null &$columnMapOut = null ]) : string
Parameters
- $operand : DynamicOperandInterface
- $source : SourceInterface
- $columnMapOut : ColumnMap|null = null
Return values
stringparseOrderings()
Transforms orderings into SQL.
protected
parseOrderings(array $orderings, SourceInterface $source) : void
Parameters
- $orderings : array
-
An array of orderings (Qom\Ordering or legacy propertyName => direction)
- $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.