In short:
I'd like to fire a SQL-Query like below with something like s.item.id
. Is this possible?
Entities:
class Set {
// ...
/**
* @ORM\ManyToOne(targetEntity="myBundle\Entity\Item")
* @ORM\JoinColumn(name="item_id", referencedColumnName="id")
*/
protected $item;
// ...
}
...
class Item {
// ...
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $id;
// ...
}
Repository
$sql = '
SELECT i.id, s.name
FROM mybundle:Item i, mybundle:Set s
WHERE s.item.id = i.id <---------------------- !!!
';
return $this->getEntityManager()
->createQueryBuilder($sql)
->getResult();