I'm doing a query and I get a strange error that I don't understand how it works or why it happens.
I'm new to symfony so bare with me.
My Goal is: To Select for a table but I want to exclude the current users data.
/**
* @param int $getIndex
* @param User $user
* @return int|mixed|string
*/
public function findByIndex(int $getIndex, User $user)
{
$queryBuilder = $this->createQueryBuilder('a');
$query = $queryBuilder->where(
$queryBuilder->expr()->eq('a.index', $getIndex),
$queryBuilder->expr()->neq('a.user', $user->getId())
)
->getQuery();
return $query->getResult();
}
I want to return the results but I don't want the current user answer.
And the error is thrown from the neq.
"[Syntax Error] line 0, col 72: Error: Expected end of string, got 'b6f037' File:/home/wwwroot/htdocs/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php Line: 52"
This is what i pass in
public function __construct(
UserRepository $userRepository,
AnswerRepository $answerRepository,
TokenStorageInterface $tokenStorage
) {
$this->userRepository = $userRepository;
$this->answerRepository = $answerRepository;
$this->user = $tokenStorage->getToken()->getUser();
}
$results = $this->answerRepository->findByIndex($dto->getIndex(), $this->user);
How can i fix this issue ?