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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With