This commit is contained in:
parent
cbdb0f9792
commit
ba61451aba
@ -1,31 +1,31 @@
|
||||
+++ Introduction
|
||||
+++ Introduction
|
||||
|
||||
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 u LEFT JOIN u.Phonenumber p
|
||||
ORDER BY u.name, p.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 LEFT JOIN u.Email e
|
||||
ORDER BY e.address DESC, u.id ASC;
|
||||
</code>
|
||||
|
||||
|
||||
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>
|
||||
|
||||
|
||||
+++ Sorting by an aggregate value
|
||||
+++ Using random order
|
||||
|
@ -34,7 +34,7 @@ class User extends Doctrine_Record
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasMany('Phonenumber', array('local' => 'id',
|
||||
'foreign' => 'user_id');
|
||||
'foreign' => 'user_id'));
|
||||
}
|
||||
}
|
||||
// file Phonenumber.php
|
||||
@ -49,7 +49,7 @@ class Phonenumber extends Doctrine_Record
|
||||
{
|
||||
$this->hasOne('User', array('local' => 'user_id',
|
||||
'foreign' => 'id',
|
||||
'onDelete' => 'CASCADE');
|
||||
'onDelete' => 'CASCADE'));
|
||||
}
|
||||
}
|
||||
</code>
|
||||
|
@ -53,7 +53,7 @@ class User extends Doctrine_Record
|
||||
public function setUp()
|
||||
{
|
||||
$this->hasMany('Phonenumber', array('local' => 'id',
|
||||
'foreign' => 'user_id');
|
||||
'foreign' => 'user_id'));
|
||||
}
|
||||
}
|
||||
// file Phonenumber.php
|
||||
@ -68,7 +68,7 @@ class Phonenumber extends Doctrine_Record
|
||||
{
|
||||
$this->hasOne('User', array('local' => 'user_id',
|
||||
'foreign' => 'id',
|
||||
'onDelete' => 'CASCADE');
|
||||
'onDelete' => 'CASCADE'));
|
||||
}
|
||||
}
|
||||
</code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user