1
0
mirror of synced 2025-01-30 20:11:49 +03:00

Added yml example in ordered-associations.rst

And modified it to be in a configuration-block instead of separate code-block
This commit is contained in:
Anthony 2013-04-03 13:31:07 -03:00
parent 9b0f252aff
commit 1278b79c79

View File

@ -12,32 +12,51 @@ collection.
Additional to any ``@OneToMany`` or ``@ManyToMany`` annotation you Additional to any ``@OneToMany`` or ``@ManyToMany`` annotation you
can specify the ``@OrderBy`` in the following way: can specify the ``@OrderBy`` in the following way:
.. code-block:: php .. configuration-block::
<?php .. code-block:: php
/** @Entity **/
class User
{
// ...
/**
* @ManyToMany(targetEntity="Group")
* @OrderBy({"name" = "ASC"})
**/
private $groups;
}
.. code-block:: xml <?php
/** @Entity **/
class User
{
// ...
/**
* @ManyToMany(targetEntity="Group")
* @OrderBy({"name" = "ASC"})
**/
private $groups;
}
<doctrine-mapping> .. code-block:: xml
<entity name="User">
<many-to-many field="groups" target-entity="Group"> <doctrine-mapping>
<order-by> <entity name="User">
<order-by-field name="name" direction="ASC" /> <many-to-many field="groups" target-entity="Group">
</order-by> <order-by>
</many-to-many> <order-by-field name="name" direction="ASC" />
</entity> </order-by>
</doctrine-mapping> </many-to-many>
</entity>
</doctrine-mapping>
.. code-block:: yaml
User:
type: entity
manyToMany:
groups:
orderBy: { 'name': 'ASC' }
targetEntity: Group
joinTable:
name: users_groups
joinColumns:
user_id:
referencedColumnName: id
inverseJoinColumns:
group_id:
referencedColumnName: id
The DQL Snippet in OrderBy is only allowed to consist of The DQL Snippet in OrderBy is only allowed to consist of
unqualified, unquoted field names and of an optional ASC/DESC unqualified, unquoted field names and of an optional ASC/DESC