如何在symfony中使用doctrine对记录进行排序?

Awa*_*wan 0 php doctrine symfony1 sql-order-by

我正在研究现有项目.获取这样的记录:

$this->courses = Doctrine_Core::getTable('Course')->findByUserId($this->userId);
Run Code Online (Sandbox Code Playgroud)

现在我想按用户名对上述记录进行排序,但我不知道怎么做?

这段代码有什么解决方案吗?

谢谢

Pau*_*uck 6

您可以:

$this->courses = Doctrine_Query::create()->from('Course c')->where('c.user_id = ?', $this->userId)->orderBy('c.user_id DESC')->execute();
Run Code Online (Sandbox Code Playgroud)