1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Enhance documentation on NEW() keyword. (ref DDC-1574)

This commit is contained in:
Benjamin Eberlei 2013-04-07 14:05:42 +02:00
parent 34374db56e
commit d1f8e18d02

View File

@ -464,14 +464,15 @@ You use the partial syntax when joining as well:
"NEW" Operator Syntax
^^^^^^^^^^^^^^^^^^^^^
Using the ``NEW`` operator you can construct DTOs from queries.
.. versionadded:: 2.4
Using the ``NEW`` operator you can construct Data Transfer Objects (DTOs) directly from DQL queries.
- When using ``SELECT NEW`` you don't need to specify a mapped entity.
- You can specify any PHP class, it's only require that you have a matching constructor in your class.
- You can specify any PHP class, it's only require that the constructor of this class matches the ``NEW`` statement.
- This approach involves determining exactly which columns you really need,
and instantiating data-transfer object that containing a constructor with those arguments.
If you want to select data-transfer objects you should create a class:
.. code-block:: php