symfony2 sort collection of objects by a property

后端 未结 1 2017
鱼传尺愫
鱼传尺愫 2021-02-15 01:21

I have this entities:

class Categoria {

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

    protected $id;

          


        
1条回答
  •  一向
    一向 (楼主)
    2021-02-15 02:11

    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)
提交回复
热议问题