有人知道为什么 nativequery 结果为空吗?
$rsm = new ResultSetMapping;
$rsm->addEntityResult('AcmeTestBundle:event', 'e');
$rsm->addFieldResult('e', 'id', 'id');
$query = $this->getEntityManager()->createNativeQuery('SELECT id FROM event WHERE publickey COLLATE latin1_general_cs = ?', $rsm);
$query->setParameter(1, $eventkey);
return $query->getSingleResult();
当我直接在 mysql 中运行查询时,我得到了正确的结果。这是从控制台创建的查询:
[2012-06-24 18:08:08] doctrine.DEBUG: SELECT id FROM event WHERE publickey COLLATE latin1_general_cs = ? (["key"]) [] []
我在另一个实体上使用相同的功能,我得到了正确的结果。有人有想法吗?
谢谢!