When using a Doctrine_Table
object, is it possible to specify the order of the returned collection when using findAll()
or findByWhatever()
?
In the doc's I see some stuff about getOrderByStatement()
and processOrderBy()
but it isn't clear on how to use them...
You can also leave the first array blank
$em->getRepository('BackendDestinyBundle:Destiny')->findBy(array(), array('title'=>'asc'));
You can in fact specify a default order by in your schema:
Foo:
columns:
...
options:
orderBy: bar DESC
Note that when you want to specify a different order, you can still create a query and override the default order by.
According to Jon Wage you should create a Query in this Case… Found in the mailing-list
In my case, the problem was that i had a statement like this
$destinos = $em->getRepository('BackendDestinyBundle:Destiny')->findAll();
finaly I changed it to a CreateQuery statement, it does exactly the same but i can put a OrderBy sentence
$destinos = $em->createQuery("SELECT d FROM BackendDestinyBundle:Destiny d order by d.name")->getResult();