我有这个实体:
class Categoria {
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue
*/
protected $id;
/** @ORMColumn(type="string", length=100) */
protected $nom;
/** @ORMColumn(type="string", length=100) */
protected $slug;
/** @ORMColumn(type="decimal", precision=3, scale=0) */
protected $ordre;
/** @ORMColumn(type="boolean", nullable=true) */
protected $actiu=FALSE;
/** @ORMColumn(type="decimal", precision=4, scale=0, nullable=true) */
protected $enllaç=null;
/** @ORMOneToMany(targetEntity="LoPatiMenuBundleEntitysubCategoria", mappedBy="categoria", cascade={"persist", "remove"} )*/
protected $subCategoria;
public function __construct()
{
$this->subCategoria = new DoctrineCommonCollectionsArrayCollection();
}
/**
* Add subCategoria
*
* @param LoPatiMenuBundleEntitysubCategoria $subCategoria
*/
public function addsubCategoria(LoPatiMenuBundleEntitysubCategoria $subCategoria)
{
$this->subCategoria[] = $subCategoria;
}
/**
* Get subCategoria
*
* @return DoctrineCommonCollectionsCollection
*/
public function getSubCategoria()
{
return $this->subCategoria;
}
和
class SubCategoria {
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue
*/
protected $id;
/** @ORMColumn(type="string", length=100) */
protected $nom;
/** @ORMColumn(type="string", length=100) */
protected $slug;
/** @ORMColumn(type="decimal", precision=3, scale=0) */
protected $ordre;
/** @ORMColumn(type="boolean", nullable=true) */
protected $actiu=FALSE;
/** @ORMColumn(type="boolean", nullable=true) */
protected $llista=FALSE;
/** @ORMColumn(type="decimal", precision=4, scale=0, nullable=true) */
protected $enllaç=null;
/** @ORMManyToOne(targetEntity="Categoria", inversedBy="subCategoria") */
protected $categoria;
在分类实体中,我想对子分类对象的集合进行排序 $ordre
.
我该怎么做?有可能在树枝神庙或实体的定义中做到这一点吗?
谢谢
问候
使用以下注释:
/**
* @ORMOneToMany(targetEntity="LoPatiMenuBundleEntitysubCategoria", mappedBy="categoria", cascade={"persist", "remove"} )
* @ORMOrderBy({"order" = "DESC", "id" = "DESC"})
*/
protected $subCategoria;
。