开发者

Doctrine 2, one to many relationship OrderBy Annotations

Hello I have got this php order by annotations on my one to many relationship

 /**
  * TaskCategory
  *
  * @Table(name="task_category")
  * @Entity(repositoryClass="models\Repositories\TaskCategoryRepository")
  */
class TaskCategory
{
 /**
  * @var array $tasks
  *
  * @OneToMany(targetEntity="Task", mappedBy="taskCategory"")
  * @OrderBy({"sort_order" = "ASC"})
  */
  private $tasks;

And I got this error:

Uncaught exception 'Doctrine\Common\Annotations\AnnotationException' with message '[Syntax Error] Expected Doctrine\Common\Annotations\Lexer::T_CLOSE_PARENTHESIS, got 'order' at position 108

Anyone got similar issue? Any advise will be greatly appreciated开发者_JS百科.


The correct annotation is

@OrderBy({"name" = "ASC"})

See: Doctrine 2 manual: Annotations reference


oops sorry I think I know the mistake it it's the double quote @OneToMany(targetEntity="Task", mappedBy="taskCategory"") suppose to be @OneToMany(targetEntity="Task", mappedBy="taskCategory")

thanks for the answer anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜