我试图在我的FacebookEventResult实体上执行本机查询,并使用我的FacebookEvent实体创建一个连接。Symfony doctrine在本机查询中未定义的索引
相关映射在FacebookEventResult:
相关映射在FacebookEvent:
/**
* @ORM\Column(type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\OneToMany(targetEntity="FacebookEventResult", mappedBy="event")
**/
protected $facebookEventResults;
我的查询代码:
$rsm = new ResultSetMapping();
$rsm->addEntityResult('AppBundle:FacebookEventResult', 'fer');
$rsm->addFieldResult('fer', 'id', 'id');
$rsm->addFieldResult('fer', 'event_date', 'eventDate');
// $rsm->addFieldResult('fer', 'facebook_event_id', 'event'); // this doesnt help
// some other mappings here as well, also tried without
$rsm->addJoinedEntityResult('AppBundle:FacebookEvent' , 'fe', 'fer', 'event');
$rsm->addFieldResult('fe', 'id', 'id');
// some other mappings here as well, also tried without
$sql = 'SELECT *
FROM facebook_event_result fer
INNER JOIN facebook_event fe ON fer.facebook_event_id = fe.id';
$query = $this->getEntityManager()->createNativeQuery($sql, $rsm);
return $query->getResult();
在执行时出现以下错误:
注意:未定义指数:ID
我曾试图按照these instructions从学说。
我认为你需要指定你想在select语句中检索的所有列字段 – Matteo
请你让我知道究竟是什么错误。把你的错误放在这里 –
他thnx回答。我以其他方式解决了这个问题,并且我没有这个代码来再次测试它 – BigJ