ResultSetMappingBuilder
extends ResultSetMapping
in package
Uses
SQLResultCasing
A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields.
Table of Contents
Constants
- COLUMN_RENAMING_CUSTOM = 2
- Picking custom renaming allows the user to define the renaming of specific columns with a rename array that contains column names as keys and result alias as values.
- COLUMN_RENAMING_INCREMENT = 3
- Incremental renaming uses a result set mapping internal counter to add a number to each column result, leading to uniqueness. This only works if you use {@see generateSelectClause()} to generate the SELECT clause for you.
- COLUMN_RENAMING_NONE = 1
- Picking this rename mode will register entity columns as is, as they are in the database. This can cause clashes when multiple entities are fetched that have columns with the same name.
Properties
- $discriminatorParameters : mixed
- Contains query parameter names to be resolved as discriminator values
- $isIdentifierColumn : mixed
- This is necessary to hydrate derivate foreign keys correctly.
- $metadataParameterMapping : mixed
- Maps metadata parameter names to the metadata attribute.
- $newObjectMappings : mixed
- Maps column names in the result set to field names for each new object expression.
- $defaultRenameMode : int
- Default column renaming mode.
- $em : EntityManagerInterface
- $sqlCounter : int
Methods
- __construct() : mixed
- __toString() : string
- addEntityResult() : $this
- Adds an entity result to this ResultSetMapping.
- addEnumResult() : $this
- Adds a scalar result mapping.
- addFieldResult() : $this
- Adds a field to the result that belongs to an entity or joined entity.
- addIndexBy() : $this
- Sets a field to use for indexing an entity result or joined entity result.
- addIndexByColumn() : $this
- Sets a column to use for indexing an entity or joined entity result by the given alias name.
- addIndexByScalar() : $this
- Sets to index by a scalar result column name.
- addJoinedEntityFromClassMetadata() : void
- Adds a joined entity and all of its fields to the result set.
- addJoinedEntityResult() : $this
- Adds a joined entity result.
- addMetadataParameterMapping() : void
- Adds a metadata parameter mappings.
- addMetaResult() : $this
- Adds a meta column (foreign key or discriminator column) to the result set.
- addNamedNativeQueryEntityResultMapping() : $this
- Adds the entity result mapping of the results of native SQL queries to the result set.
- addNamedNativeQueryMapping() : ResultSetMappingBuilder
- Adds the mappings of the results of native SQL queries to the result set.
- addNamedNativeQueryResultClassMapping() : $this
- Adds the class mapping of the results of native SQL queries to the result set.
- addNamedNativeQueryResultSetMapping() : $this
- Adds the result set mapping of the results of native SQL queries to the result set.
- addRootEntityFromClassMetadata() : void
- Adds a root entity and all of its fields to the result set.
- addScalarResult() : $this
- Adds a scalar result mapping.
- generateSelectClause() : string
- Generates the Select clause from this ResultSetMappingBuilder.
- getAliasMap() : mixed
- getClassName() : class-string
- Gets the name of the class of an entity result or joined entity result, identified by the given unique alias.
- getDeclaringClass() : class-string
- Gets the name of the class that owns a field mapping for the specified column.
- getEntityAlias() : string
- Gets the alias of the class that owns a field mapping for the specified column.
- getEntityResultCount() : int
- Gets the number of different entities that appear in the mapped result.
- getFieldName() : string
- Gets the field name for a column name.
- getParentAlias() : string
- Gets the parent alias of the given alias.
- getRelation() : string
- getScalarAlias() : string|int
- Gets the field alias for a column that is mapped as a scalar value.
- hasIndexBy() : bool
- Checks whether an entity result or joined entity result with a given alias has a field set for indexing.
- hasParentAlias() : bool
- Checks whether the given alias has a parent alias.
- isFieldResult() : bool
- Checks whether the column with the given name is mapped as a field result as part of an entity result or joined entity result.
- isMixedResult() : bool
- Checks whether this ResultSetMapping defines a mixed result.
- isRelation() : bool
- isScalarResult() : bool
- Checks whether a column with a given name is mapped as a scalar result.
- setDiscriminatorColumn() : $this
- Sets a discriminator column for an entity result or joined entity result.
- addAllClassFields() : void
- Adds all fields of the given class to the result set mapping (columns and meta fields).
- getColumnAlias() : string
- Gets column alias for a given column.
- getColumnAliasMap() : array<string|int, string>
- Retrieves a class columns and join columns aliases that are used in the SELECT clause.
- isInheritanceSupported() : bool
Constants
COLUMN_RENAMING_CUSTOM
Picking custom renaming allows the user to define the renaming of specific columns with a rename array that contains column names as keys and result alias as values.
public
mixed
COLUMN_RENAMING_CUSTOM
= 2
COLUMN_RENAMING_INCREMENT
Incremental renaming uses a result set mapping internal counter to add a number to each column result, leading to uniqueness. This only works if you use {@see generateSelectClause()} to generate the SELECT clause for you.
public
mixed
COLUMN_RENAMING_INCREMENT
= 3
COLUMN_RENAMING_NONE
Picking this rename mode will register entity columns as is, as they are in the database. This can cause clashes when multiple entities are fetched that have columns with the same name.
public
mixed
COLUMN_RENAMING_NONE
= 1
Properties
$discriminatorParameters
Contains query parameter names to be resolved as discriminator values
public
mixed
$discriminatorParameters
= []
Tags
$isIdentifierColumn
This is necessary to hydrate derivate foreign keys correctly.
public
mixed
$isIdentifierColumn
= []
Tags
$metadataParameterMapping
Maps metadata parameter names to the metadata attribute.
public
mixed
$metadataParameterMapping
= []
Tags
$newObjectMappings
Maps column names in the result set to field names for each new object expression.
public
mixed
$newObjectMappings
= []
Tags
$defaultRenameMode
Default column renaming mode.
private
int
$defaultRenameMode
Tags
$em
private
EntityManagerInterface
$em
$sqlCounter
private
int
$sqlCounter
= 0
Methods
__construct()
public
__construct(EntityManagerInterface $em[, int $defaultRenameMode = self::COLUMN_RENAMING_NONE ]) : mixed
Parameters
- $em : EntityManagerInterface
- $defaultRenameMode : int = self::COLUMN_RENAMING_NONE
Tags
__toString()
public
__toString() : string
Return values
stringaddEntityResult()
Adds an entity result to this ResultSetMapping.
public
addEntityResult(string $class, string $alias[, string|null $resultAlias = null ]) : $this
Parameters
- $class : string
-
The class name of the entity.
- $alias : string
-
The alias for the class. The alias must be unique among all entity results or joined entity results within this ResultSetMapping.
- $resultAlias : string|null = null
-
The result alias with which the entity result should be placed in the result structure.
Tags
Return values
$thisaddEnumResult()
Adds a scalar result mapping.
public
addEnumResult(string $columnName, string $enumType) : $this
Parameters
- $columnName : string
-
The name of the column in the SQL result set.
- $enumType : string
-
The enum type
Return values
$thisaddFieldResult()
Adds a field to the result that belongs to an entity or joined entity.
public
addFieldResult(string $alias, string $columnName, string $fieldName[, string|null $declaringClass = null ]) : $this
Parameters
- $alias : string
-
The alias of the root entity or joined entity to which the field belongs.
- $columnName : string
-
The name of the column in the SQL result set.
- $fieldName : string
-
The name of the field on the declaring class.
- $declaringClass : string|null = null
-
The name of the class that declares/owns the specified field. When $alias refers to a superclass in a mapped hierarchy but the field $fieldName is defined on a subclass, specify that here. If not specified, the field is assumed to belong to the class designated by $alias.
Tags
Return values
$thisaddIndexBy()
Sets a field to use for indexing an entity result or joined entity result.
public
addIndexBy(string $alias, string $fieldName) : $this
Parameters
- $alias : string
-
The alias of an entity result or joined entity result.
- $fieldName : string
-
The name of the field to use for indexing.
Return values
$thisaddIndexByColumn()
Sets a column to use for indexing an entity or joined entity result by the given alias name.
public
addIndexByColumn(string $alias, string $resultColumnName) : $this
Parameters
- $alias : string
- $resultColumnName : string
Return values
$thisaddIndexByScalar()
Sets to index by a scalar result column name.
public
addIndexByScalar(string $resultColumnName) : $this
Parameters
- $resultColumnName : string
Return values
$thisaddJoinedEntityFromClassMetadata()
Adds a joined entity and all of its fields to the result set.
public
addJoinedEntityFromClassMetadata(string $class, string $alias, string $parentAlias, string $relation[, array<string|int, string> $renamedColumns = [] ][, int|null $renameMode = null ]) : void
Parameters
- $class : string
-
The class name of the joined entity.
- $alias : string
-
The unique alias to use for the joined entity.
- $parentAlias : string
-
The alias of the entity result that is the parent of this joined result.
- $relation : string
-
The association field that connects the parent entity result with the joined entity result.
- $renamedColumns : array<string|int, string> = []
-
Columns that have been renamed (tableColumnName => queryColumnName).
- $renameMode : int|null = null
-
One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM).
Tags
addJoinedEntityResult()
Adds a joined entity result.
public
addJoinedEntityResult(string $class, string $alias, string $parentAlias, string $relation) : $this
Parameters
- $class : string
-
The class name of the joined entity.
- $alias : string
-
The unique alias to use for the joined entity.
- $parentAlias : string
-
The alias of the entity result that is the parent of this joined result.
- $relation : string
-
The association field that connects the parent entity result with the joined entity result.
Tags
Return values
$thisaddMetadataParameterMapping()
Adds a metadata parameter mappings.
public
addMetadataParameterMapping(string|int $parameter, string $attribute) : void
Parameters
- $parameter : string|int
-
The parameter name in the SQL result set.
- $attribute : string
-
The metadata attribute.
addMetaResult()
Adds a meta column (foreign key or discriminator column) to the result set.
public
addMetaResult(string $alias, string $columnName, string $fieldName[, bool $isIdentifierColumn = false ][, string|null $type = null ]) : $this
Parameters
- $alias : string
-
The result alias with which the meta result should be placed in the result structure.
- $columnName : string
-
The name of the column in the SQL result set.
- $fieldName : string
-
The name of the field on the declaring class.
- $isIdentifierColumn : bool = false
- $type : string|null = null
-
The column type
Tags
Return values
$thisaddNamedNativeQueryEntityResultMapping()
Adds the entity result mapping of the results of native SQL queries to the result set.
public
addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array<string|int, mixed> $entityMapping, string $alias) : $this
Parameters
- $classMetadata : ClassMetadataInfo
- $entityMapping : array<string|int, mixed>
- $alias : string
Tags
Return values
$thisaddNamedNativeQueryMapping()
Adds the mappings of the results of native SQL queries to the result set.
public
addNamedNativeQueryMapping(ClassMetadataInfo $class, array<string|int, mixed> $queryMapping) : ResultSetMappingBuilder
Parameters
- $class : ClassMetadataInfo
- $queryMapping : array<string|int, mixed>
Tags
Return values
ResultSetMappingBuilderaddNamedNativeQueryResultClassMapping()
Adds the class mapping of the results of native SQL queries to the result set.
public
addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, string $resultClassName) : $this
Parameters
- $class : ClassMetadataInfo
- $resultClassName : string
Tags
Return values
$thisaddNamedNativeQueryResultSetMapping()
Adds the result set mapping of the results of native SQL queries to the result set.
public
addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, string $resultSetMappingName) : $this
Parameters
- $class : ClassMetadataInfo
- $resultSetMappingName : string
Tags
Return values
$thisaddRootEntityFromClassMetadata()
Adds a root entity and all of its fields to the result set.
public
addRootEntityFromClassMetadata(string $class, string $alias[, array<string|int, string> $renamedColumns = [] ][, int|null $renameMode = null ]) : void
Parameters
- $class : string
-
The class name of the root entity.
- $alias : string
-
The unique alias to use for the root entity.
- $renamedColumns : array<string|int, string> = []
-
Columns that have been renamed (tableColumnName => queryColumnName).
- $renameMode : int|null = null
-
One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM).
Tags
addScalarResult()
Adds a scalar result mapping.
public
addScalarResult(string $columnName, string|int $alias[, string $type = 'string' ]) : $this
Parameters
- $columnName : string
-
The name of the column in the SQL result set.
- $alias : string|int
-
The result alias with which the scalar result should be placed in the result structure.
- $type : string = 'string'
-
The column type
Tags
Return values
$thisgenerateSelectClause()
Generates the Select clause from this ResultSetMappingBuilder.
public
generateSelectClause([array<string|int, string> $tableAliases = [] ]) : string
Works only for all the entity results. The select parts for scalar expressions have to be written manually.
Parameters
- $tableAliases : array<string|int, string> = []
Tags
Return values
stringgetAliasMap()
public
getAliasMap() : mixed
Tags
getClassName()
Gets the name of the class of an entity result or joined entity result, identified by the given unique alias.
public
getClassName(string $alias) : class-string
Parameters
- $alias : string
Return values
class-stringgetDeclaringClass()
Gets the name of the class that owns a field mapping for the specified column.
public
getDeclaringClass(string $columnName) : class-string
Parameters
- $columnName : string
Return values
class-stringgetEntityAlias()
Gets the alias of the class that owns a field mapping for the specified column.
public
getEntityAlias(string $columnName) : string
Parameters
- $columnName : string
Return values
stringgetEntityResultCount()
Gets the number of different entities that appear in the mapped result.
public
getEntityResultCount() : int
Tags
Return values
intgetFieldName()
Gets the field name for a column name.
public
getFieldName(string $columnName) : string
Parameters
- $columnName : string
Return values
stringgetParentAlias()
Gets the parent alias of the given alias.
public
getParentAlias(string $alias) : string
Parameters
- $alias : string
Return values
stringgetRelation()
public
getRelation(string $alias) : string
Parameters
- $alias : string
Return values
stringgetScalarAlias()
Gets the field alias for a column that is mapped as a scalar value.
public
getScalarAlias(string $columnName) : string|int
Parameters
- $columnName : string
-
The name of the column in the SQL result set.
Return values
string|inthasIndexBy()
Checks whether an entity result or joined entity result with a given alias has a field set for indexing.
public
hasIndexBy(string $alias) : bool
Parameters
- $alias : string
Tags
Return values
boolhasParentAlias()
Checks whether the given alias has a parent alias.
public
hasParentAlias(string $alias) : bool
Parameters
- $alias : string
Return values
boolisFieldResult()
Checks whether the column with the given name is mapped as a field result as part of an entity result or joined entity result.
public
isFieldResult(string $columnName) : bool
Parameters
- $columnName : string
-
The name of the column in the SQL result set.
Tags
Return values
boolisMixedResult()
Checks whether this ResultSetMapping defines a mixed result.
public
isMixedResult() : bool
Mixed results can only occur in object and array (graph) hydration. In such a case a mixed result means that scalar values are mixed with objects/array in the result.
Return values
boolisRelation()
public
isRelation(string $alias) : bool
Parameters
- $alias : string
Return values
boolisScalarResult()
Checks whether a column with a given name is mapped as a scalar result.
public
isScalarResult(string $columnName) : bool
Parameters
- $columnName : string
-
The name of the column in the SQL result set.
Tags
Return values
boolsetDiscriminatorColumn()
Sets a discriminator column for an entity result or joined entity result.
public
setDiscriminatorColumn(string $alias, string $discrColumn) : $this
The discriminator column will be used to determine the concrete class name to instantiate.
Parameters
- $alias : string
-
The alias of the entity result or joined entity result the discriminator column should be used for.
- $discrColumn : string
-
The name of the discriminator column in the SQL result set.
Tags
Return values
$thisaddAllClassFields()
Adds all fields of the given class to the result set mapping (columns and meta fields).
protected
addAllClassFields(string $class, string $alias[, array<string|int, string> $columnAliasMap = [] ]) : void
Parameters
- $class : string
- $alias : string
- $columnAliasMap : array<string|int, string> = []
Tags
getColumnAlias()
Gets column alias for a given column.
private
getColumnAlias(string $columnName, int $mode, array<string|int, mixed> $customRenameColumns) : string
Parameters
- $columnName : string
- $mode : int
- $customRenameColumns : array<string|int, mixed>
Tags
Return values
stringgetColumnAliasMap()
Retrieves a class columns and join columns aliases that are used in the SELECT clause.
private
getColumnAliasMap(string $className, int $mode, array<string|int, mixed> $customRenameColumns) : array<string|int, string>
This depends on the renaming mode selected by the user.
Parameters
- $className : string
- $mode : int
- $customRenameColumns : array<string|int, mixed>
Tags
Return values
array<string|int, string>isInheritanceSupported()
private
isInheritanceSupported(ClassMetadata $classMetadata) : bool
Parameters
- $classMetadata : ClassMetadata