I have an issue with my query if when I have this following setup.
I have an entity
<?php
class EntityB
{
/**
* @ORM\ManyToOne(targetEntity="EntityA", inversedBy="someKeyWord")
* @ORM\JoinColumn(name="entityA_id", referencedColumnName="id")
*/
private $entityA;
}
Now when you query and get an array as result, it works
// EntityBRepository.php
public function querySomeStuff($isArray=false)
{
$b = $entityManager->createQuery('
SELECT partial eA.{id, title}
FROM EntityB eB
LEFT JOIN eB.entityA eA
');
if ($isArray) {
$r = $b->getArrayResult();
} else {
$r = $b->getResult();
}
if (count($r)) {
return $r[0];
} else {
return null;
}
}
But if I do the same function call but pass the 2nd parameter as false, meaning, I don't want to get the result as an array, it crashes saying Notice: Undefined index: someKeyWord
.
This is related to doctrine inversedBy mapping with partial left join query.