Iterate Doctrine Collection ordered by some field

后端 未结 4 1455
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 16:34

I need something like this:

        $products = Products::getTable()->find(274);
        foreach ($products->Categories->orderBy(\'title\') as $category         


        
4条回答
  •  既然无缘
    2021-02-19 17:11

    You can also do:

    $this->hasMany('Category as Categories', array(...
                 'orderBy' => 'title ASC'));
    

    In your schema file it looks like:

      Relations:
        Categories:
          class: Category
          ....
          orderBy: title ASC
    

提交回复
热议问题