symfony2 sort collection of objects by a property

后端 未结 1 492
刺人心
刺人心 2021-02-15 01:42

I have this entities:

class Categoria {

    /**
     * @ORM\\Id
     * @ORM\\Column(type=\"integer\")
     * @ORM\\GeneratedValue
     */

    protected $id;

          


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-15 02:02

    Use this annotation:

    /** 
     * @ORM\OneToMany(targetEntity="LoPati\MenuBundle\Entity\subCategoria", mappedBy="categoria", cascade={"persist", "remove"} )
     * @ORM\OrderBy({"order" = "DESC", "id" = "DESC"})
    */
    protected $subCategoria;
    

    ...

    0 讨论(0)
提交回复
热议问题