class ResultSetMapping (View source)

A ResultSetMapping describes how a result set of an SQL query maps to a Doctrine result.

IMPORTANT NOTE: The properties of this class are only public for fast internal READ access and to (drastically) reduce the size of serialized instances for more effective caching due to better (un-)serialization performance.

Users should use the public methods.

Properties

bool $isMixed Whether the result is mixed (contains scalar values together with field values).
bool $isSelect Whether the result is a select statement.
string[] $aliasMap Maps alias names to class names.
string[] $relationMap Maps alias names to related association field names.
string[] $parentAliasMap Maps alias names to parent alias names.
string[] $fieldMappings Maps column names in the result set to field names for each class.
string[] $scalarMappings Maps column names in the result set to the alias/field name to use in the mapped result.
Type[] $typeMappings Maps column names in the result set to the alias/field type to use in the mapped result.
string[] $entityMappings Maps entities in the result set to the alias name to use in the mapped result.
string[] $metaMappings Maps column names of meta columns (foreign keys, discriminator columns, .
string[] $columnOwnerMap Maps column names in the result set to the alias they belong to.
string[] $discriminatorColumns List of columns in the result set that are used as discriminator columns.
string[] $indexByMap Maps alias names to field names that should be used for indexing.
string[] $declaringClasses Map from column names to class names that declare the field the column is mapped to.
bool[][] $isIdentifierColumn This is necessary to hydrate derivate foreign keys correctly.
mixed[][] $newObjectMappings Maps column names in the result set to field names for each new object expression.
mixed[] $metadataParameterMapping Maps metadata parameter names to the metadata attribute.
string[] $discriminatorParameters Contains query parameter names to be resolved as discriminator values

Methods

addEntityResult(string $class, string $alias, string|null $resultAlias = null)

Adds an entity result to this ResultSetMapping.

setDiscriminatorColumn(string $alias, string $discrColumn)

Sets a discriminator column for an entity result or joined entity result.

addIndexBy(string $alias, string $fieldName)

Sets a field to use for indexing an entity result or joined entity result.

addIndexByScalar(string $resultColumnName)

Sets to index by a scalar result column name.

addIndexByColumn(string $alias, string $resultColumnName)

Sets a column to use for indexing an entity or joined entity result by the given alias name.

bool
hasIndexBy(string $alias)

Checks whether an entity result or joined entity result with a given alias has a field set for indexing.

bool
isFieldResult(string $columnName)

Checks whether the column with the given name is mapped as a field result as part of an entity result or joined entity result.

addFieldResult(string $alias, string $columnName, string $fieldName, string|null $declaringClass = null)

Adds a field to the result that belongs to an entity or joined entity.

addJoinedEntityResult(string $class, string $alias, string $parentAlias, string $relation)

Adds a joined entity result.

addScalarResult(string $columnName, string $alias, Type $type)

Adds a scalar result mapping.

bool
isScalarResult(string $columnName)

Checks whether a column with a given name is mapped as a scalar result.

string
getClassName(string $alias)

Gets the name of the class of an entity result or joined entity result, identified by the given unique alias.

string
getScalarAlias(string $columnName)

Gets the field alias for a column that is mapped as a scalar value.

string
getDeclaringClass(string $columnName)

Gets the name of the class that owns a field mapping for the specified column.

getRelation(string $alias)

No description

bool
isRelation(string $alias)

No description

string
getEntityAlias(string $columnName)

Gets the alias of the class that owns a field mapping for the specified column.

string
getParentAlias(string $alias)

Gets the parent alias of the given alias.

bool
hasParentAlias(string $alias)

Checks whether the given alias has a parent alias.

string
getFieldName(string $columnName)

Gets the field name for a column name.

string[]
getAliasMap()

No description

int
getEntityResultCount()

Gets the number of different entities that appear in the mapped result.

bool
isMixedResult()

Checks whether this ResultSetMapping defines a mixed result.

addMetaResult(string $alias, string $columnName, string $fieldName, bool $isIdentifierColumn, Type $type)

Adds a meta column (foreign key or discriminator column) to the result set.

Details

ResultSetMapping addEntityResult(string $class, string $alias, string|null $resultAlias = null)

Adds an entity result to this ResultSetMapping.

Parameters

string $class The class name of the entity.
string $alias The alias for the class. The alias must be unique among all entity results or joined entity results within this ResultSetMapping.
string|null $resultAlias The result alias with which the entity result should be placed in the result structure.

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping setDiscriminatorColumn(string $alias, string $discrColumn)

Sets a discriminator column for an entity result or joined entity result.

The discriminator column will be used to determine the concrete class name to instantiate.

Parameters

string $alias The alias of the entity result or joined entity result the discriminator column should be used for.
string $discrColumn The name of the discriminator column in the SQL result set.

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping addIndexBy(string $alias, string $fieldName)

Sets a field to use for indexing an entity result or joined entity result.

Parameters

string $alias The alias of an entity result or joined entity result.
string $fieldName The name of the field to use for indexing.

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping addIndexByScalar(string $resultColumnName)

Sets to index by a scalar result column name.

Parameters

string $resultColumnName

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping addIndexByColumn(string $alias, string $resultColumnName)

Sets a column to use for indexing an entity or joined entity result by the given alias name.

Parameters

string $alias
string $resultColumnName

Return Value

ResultSetMapping This ResultSetMapping instance.

bool hasIndexBy(string $alias)

Checks whether an entity result or joined entity result with a given alias has a field set for indexing.

Parameters

string $alias

Return Value

bool

bool isFieldResult(string $columnName)

Checks whether the column with the given name is mapped as a field result as part of an entity result or joined entity result.

Parameters

string $columnName The name of the column in the SQL result set.

Return Value

bool

ResultSetMapping addFieldResult(string $alias, string $columnName, string $fieldName, string|null $declaringClass = null)

Adds a field to the result that belongs to an entity or joined entity.

Parameters

string $alias The alias of the root entity or joined entity to which the field belongs.
string $columnName The name of the column in the SQL result set.
string $fieldName The name of the field on the declaring class.
string|null $declaringClass 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.

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping addJoinedEntityResult(string $class, string $alias, string $parentAlias, string $relation)

Adds a joined entity result.

Parameters

string $class The class name of the joined entity.
string $alias The unique alias to use for the joined entity.
string $parentAlias The alias of the entity result that is the parent of this joined result.
string $relation The association field that connects the parent entity result with the joined entity result.

Return Value

ResultSetMapping This ResultSetMapping instance.

ResultSetMapping addScalarResult(string $columnName, string $alias, Type $type)

Adds a scalar result mapping.

Parameters

string $columnName The name of the column in the SQL result set.
string $alias The result alias with which the scalar result should be placed in the result structure.
Type $type The column type

Return Value

ResultSetMapping This ResultSetMapping instance.

bool isScalarResult(string $columnName)

Checks whether a column with a given name is mapped as a scalar result.

Parameters

string $columnName The name of the column in the SQL result set.

Return Value

bool

string getClassName(string $alias)

Gets the name of the class of an entity result or joined entity result, identified by the given unique alias.

Parameters

string $alias

Return Value

string

string getScalarAlias(string $columnName)

Gets the field alias for a column that is mapped as a scalar value.

Parameters

string $columnName The name of the column in the SQL result set.

Return Value

string

string getDeclaringClass(string $columnName)

Gets the name of the class that owns a field mapping for the specified column.

Parameters

string $columnName

Return Value

string

AssociationMetadata getRelation(string $alias)

Parameters

string $alias

Return Value

AssociationMetadata

bool isRelation(string $alias)

Parameters

string $alias

Return Value

bool

string getEntityAlias(string $columnName)

Gets the alias of the class that owns a field mapping for the specified column.

Parameters

string $columnName

Return Value

string

string getParentAlias(string $alias)

Gets the parent alias of the given alias.

Parameters

string $alias

Return Value

string

bool hasParentAlias(string $alias)

Checks whether the given alias has a parent alias.

Parameters

string $alias

Return Value

bool

string getFieldName(string $columnName)

Gets the field name for a column name.

Parameters

string $columnName

Return Value

string

string[] getAliasMap()

Return Value

string[]

int getEntityResultCount()

Gets the number of different entities that appear in the mapped result.

Return Value

int

bool isMixedResult()

Checks whether this ResultSetMapping defines a mixed result.

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 Value

bool

ResultSetMapping addMetaResult(string $alias, string $columnName, string $fieldName, bool $isIdentifierColumn, Type $type)

Adds a meta column (foreign key or discriminator column) to the result set.

Parameters

string $alias The result alias with which the meta result should be placed in the result structure.
string $columnName The name of the column in the SQL result set.
string $fieldName The name of the field on the declaring class.
bool $isIdentifierColumn
Type $type The column type

Return Value

ResultSetMapping This ResultSetMapping instance.