CoolCMS API

PersistedValuesTrait

Raw read of the stored values of a row, for gates in `beforeSave()` that compare the new state with the database state on UPDATE (for example "does the response price or currency change?").

IMPORTANT: it uses direct DBAL, not find(). On the save path the entity is managed and already mutated by hydration, so find() returns the same identity-map instance holding the new values and the comparison would always see no change. Table and column names come from entity metadata.

Tags
requires

OrmRepository getClassMetadata(), getEntityManager()

Table of Contents

Methods

findPersistedValues()  : array<string, mixed>|null

Methods

findPersistedValues()

public findPersistedValues(int $id, array<int, string> $fields) : array<string, mixed>|null
Parameters
$id : int
$fields : array<int, string>

entity property names (price, currencyId)

Return values
array<string, mixed>|null —

map of property to stored value; null when the row does not exist or the query failed

On this page

Search results