class ScalarHydrator extends AbstractHydrator (View source)

Hydrator that produces flat, rectangular results of scalar data.

The created result is almost the same as a regular SQL result set, except that column names are mapped to field names and data type conversions take place.

Properties

protected ResultSetMapping $_rsm The ResultSetMapping. from AbstractHydrator
protected EntityManagerInterface $_em The EntityManager instance. from AbstractHydrator
protected AbstractPlatform $_platform The dbms Platform instance. from AbstractHydrator
protected UnitOfWork $_uow The UnitOfWork of the associated EntityManager. from AbstractHydrator
protected array $_metadataCache Local ClassMetadata cache to avoid going to the EntityManager all the time. from AbstractHydrator
protected array $_cache The cache used during row-by-row hydration. from AbstractHydrator
protected Statement $_stmt The statement that provides the data to hydrate. from AbstractHydrator
protected array $_hints The query hints. from AbstractHydrator

Methods

__construct(EntityManagerInterface $em)

Initializes a new instance of a class derived from AbstractHydrator.

iterate(object $stmt, object $resultSetMapping, array $hints = array())

Initiates a row-by-row hydration.

array
hydrateAll(object $stmt, object $resultSetMapping, array $hints = array())

Hydrates all rows returned by the passed statement instance at once.

mixed
hydrateRow()

Hydrates a single row returned by the current statement instance during row-by-row hydration with {@link iterate()}.

void
onClear(mixed $eventArgs)

When executed in a hydrate() loop we have to clear internal state to decrease memory consumption.

void
prepare()

Executes one-time preparation tasks, once each time hydration is started through {@link hydrateAll} or {@link iterate()}.

void
cleanup()

Executes one-time cleanup tasks at the end of a hydration that was initiated through {@link hydrateAll} or {@link iterate()}.

void
hydrateRowData(array $data, array $result)

Hydrates a single row from the current statement instance.

array
hydrateAllData()

Hydrates all rows from the current statement instance at once.

array
gatherRowData(array $data, array $id, array $nonemptyComponents)

Processes a row of the result set.

array
gatherScalarRowData(array $data)

Processes a row of the result set.

array|null
hydrateColumnInfo(string $key)

Retrieve column information from ResultSetMapping.

getClassMetadata(string $className)

Retrieve ClassMetadata associated to entity class name.

void
registerManaged(ClassMetadata $class, object $entity, array $data)

Register entity as managed in UnitOfWork.

Details

__construct(EntityManagerInterface $em)

Initializes a new instance of a class derived from AbstractHydrator.

Parameters

EntityManagerInterface $em The EntityManager to use.

IterableResult iterate(object $stmt, object $resultSetMapping, array $hints = array())

Initiates a row-by-row hydration.

Parameters

object $stmt
object $resultSetMapping
array $hints

Return Value

IterableResult

array hydrateAll(object $stmt, object $resultSetMapping, array $hints = array())

Hydrates all rows returned by the passed statement instance at once.

Parameters

object $stmt
object $resultSetMapping
array $hints

Return Value

array

mixed hydrateRow()

Hydrates a single row returned by the current statement instance during row-by-row hydration with {@link iterate()}.

Return Value

mixed

void onClear(mixed $eventArgs)

When executed in a hydrate() loop we have to clear internal state to decrease memory consumption.

Parameters

mixed $eventArgs

Return Value

void

protected void prepare()

Executes one-time preparation tasks, once each time hydration is started through {@link hydrateAll} or {@link iterate()}.

Return Value

void

protected void cleanup()

Executes one-time cleanup tasks at the end of a hydration that was initiated through {@link hydrateAll} or {@link iterate()}.

Return Value

void

protected void hydrateRowData(array $data, array $result)

Hydrates a single row from the current statement instance.

Template method.

Parameters

array $data The row data.
array $result The result to fill.

Return Value

void

Exceptions

HydrationException

protected array hydrateAllData()

Hydrates all rows from the current statement instance at once.

Return Value

array

protected array gatherRowData(array $data, array $id, array $nonemptyComponents)

Processes a row of the result set.

Used for identity-based hydration (HYDRATE_OBJECT and HYDRATE_ARRAY). Puts the elements of a result row into a new array, grouped by the dql alias they belong to. The column names in the result set are mapped to their field names during this procedure as well as any necessary conversions on the values applied. Scalar values are kept in a specific key 'scalars'.

Parameters

array $data SQL Result Row.
array $id &$id Dql-Alias => ID-Hash.
array $nonemptyComponents &$nonemptyComponents Does this DQL-Alias has at least one non NULL value?

Return Value

array An array with all the fields (name => value) of the data row, grouped by their component alias.

protected array gatherScalarRowData(array $data)

Processes a row of the result set.

Used for HYDRATE_SCALAR. This is a variant of _gatherRowData() that simply converts column names to field names and properly converts the values according to their types. The resulting row has the same number of elements as before.

Parameters

array $data

Return Value

array The processed row.

protected array|null hydrateColumnInfo(string $key)

Retrieve column information from ResultSetMapping.

Parameters

string $key Column name

Return Value

array|null

protected ClassMetadata getClassMetadata(string $className)

Retrieve ClassMetadata associated to entity class name.

Parameters

string $className

Return Value

ClassMetadata

protected void registerManaged(ClassMetadata $class, object $entity, array $data)

Register entity as managed in UnitOfWork.

Parameters

ClassMetadata $class
object $entity
array $data

Return Value

void