Doctrine_Core::getTable()->findAll() how to specify order?

岁酱吖の 提交于 2019-12-03 09:39:42

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

Jorge Ibacache

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!