1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/manual/docs/DQL (Doctrine Query Language) - ORDER BY clause - Introduction.php
2007-04-13 21:49:11 +00:00

26 lines
654 B
PHP

Record collections can be sorted efficiently at the database level using the ORDER BY clause.
Syntax:
<code>
[ORDER BY {ComponentAlias.columnName}
[ASC | DESC], ...]
</code>
Examples:
<code>
FROM User.Phonenumber
ORDER BY User.name, Phonenumber.phonenumber
FROM User u, u.Email e
ORDER BY e.address, u.id
</code>
In order to sort in reverse order you can add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.
<code>
FROM User u, u.Email e
ORDER BY e.address DESC, u.id ASC;
</code>