Doctrine 2, One to Many Relationships OrderBy Annotations

Hello, I have this php order for annotations in 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 

Has anyone got a similar issue? Any recommendations would be greatly appreciated.

+4
source share
2 answers

oops sorry I think I know the error, this is a double quote @OneToMany (targetEntity = "Task", mappedBy = "taskCategory" ") should be @OneToMany (targetEntity =" Task ", mappedBy =" taskCategory ")

Thanks for the reply anyway.

+3
source

Correct annotation

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

See: Doctrine 2 Guide: Annotation Link

+10
source

All Articles