mirror of
https://github.com/doctrine/orm.git
synced 2026-04-30 01:43:20 +02:00
DQL docs - I'll write clarifications in the docs if someone can elaborate a few things #5609
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bitwombat on GitHub (Jul 19, 2017).
Originally assigned to: @Ocramius on GitHub.
Hi Contributors,
I think there are some behaviours/logic in DQL usage that aren't clear in the documentation.
"The select clause of a DQL query specifies what appears in the
query result. "
Is it more that what is selected is hydrated? Because what 'appears' in the result is an array of the entity specified by FROM, yes?
SELECT u.name, u.usernamevs
SELECT uvs
SELECT u, u.nameIt's unclear from the docs what this difference is. I haven't done enough experimenting yet, but I know if I don't have at least the FROM entity in the SELECT, I get "Cannot select entity through identification variables without choosing at least one root entity alias."
I'd like to write the clarifications and submit a PR, but I need a bit of help making sure I understand.
Thanks!
Greg
@Ocramius commented on GitHub (Jul 21, 2017):
You are correct - fetch-joins will hydrate INTO the root of the selection. Technically, it is still what is being put in the result, just not in a very intuitive way.
Yes, the first one will give you an array of scalars per row, the second one an entity per row, the third an array with the entity and the scalar.
You can select scalars from any entity in the selection, you can select the entity in the
FROM, but you cannot select other entities unless you also select the root of the selection (first entity inFROM).WHEREis applied to the results of an entire queryWITHis applied to a join as an additional condition. For arbitrary joins (SELECT f, b FROM Foo f, Bar b WITH f.id = b.id) theWITHis required, even if it is1 = 1HAVINGis applied to the results of a query after aggregation (GROUP BY)@Ocramius commented on GitHub (Aug 18, 2017):
Closing here: moved to #6572