I am using a custom FindBy filter where I want to pass orderBy and orderDirection as parameters like this:
public function findByFilter($filter, $orderBy = null, $orderDirection = null)
{
...
return $this->getEntityManager()->createQuery(
'SELECT i FROM ' . $entityName . ' i ' .
'WHERE i.id LIKE :id'
. ($orderBy) ? ' ORDER BY i.' . $orderBy : ''
. ($orderDirection) ? ' ' . $orderDirection : ''
)
->setParameter('id', $filter)
->getResult()
;
}
I am getting the following error message:
[Syntax Error] line 0, col 1: Error: Expected SELECT, UPDATE or DELETE, got 'ASC'