This is my function:
public function findByIdJoinedToCategory($id)
{
$query = $this->getEntityManager()
->createQuery(
'SELECT a, b
FROM App\Entity\Products a
JOIN a.productgroup b
WHERE a.id = 2');
}
I simply try to replace 2 with the variable $id. But I do not succeed:
public function findByIdJoinedToCategory($id)
{
$query = $this->getEntityManager()
->createQuery(
'SELECT a, b
FROM App\Entity\Products a
JOIN a.productgroup b
WHERE a.id = $id');
}
I get the error message:
[Syntax Error] line 0, col 125: Error: Expected Literal, got '$'