I have a Doctrine model (Assignment
), which has a many-to-one relationship with another model (Region
). Assignments are owned by users (with each user having only one assignment per region at a time), and I am trying to use indexBy
to have the user's array of assignments be keyed by the ID of the assignment's region. However, I only get standard 0..n numeric keys.
When I try to run a DQL query like SELECT am, reg, user FROM Assignment am INDEX BY [...] JOIN am.region reg JOIN am.user user WHERE user.id = ?1
, none of these values for INDEX BY work:
region
(Error: Invalid PathExpression. Must be a StateFieldPathExpression.)region_id
(Error: Class ...\Assignment has no field or association named region_id)region.id
(Error: Expected end of string, got '.')
Is this possible? If not, then what would be a convenient way to access a User
's assignment on a region without indexBy
?
[Semantical Error] line 0, col 121 near 'alert WHERE clientAlert.client': Error: 'alert' is already defined.
. – Proa