'as'中的Doctrine2本机查询水合器错误

时间:2012-09-20 18:01:19

标签: orm symfony doctrine doctrine-orm

我希望使用使用'as'子句的本机查询来设置类属性:

public function findIntersects($id,$pontos){

$em = $this->getEntityManager();

 $sql = "SELECT p.imovel,p.id,ST_Area(ST_Intersection(p.location,'POLYGON((".$pontos."))')) as area_int, ST_Area(p.location) as area from propriedades p where ST_Intersects(p.location,'POLYGON((".$pontos."))') and id !=:id";

$rsm = new ResultSetMapping;
$rsm->addEntityResult('Incra\PropriedadesBundle\Entity\Propriedades', 'o');
$rsm->addFieldResult('o', 'id', 'id');
$rsm->addFieldResult('o', 'imovel', 'imovel');
$rsm->addFieldResult('o', 'area_int', 'area_int');
$rsm->addFieldResult('o', 'area', 'area');

 $qns = $this->_em->createNativeQuery($sql, $rsm);
$qns->setParameter("id", $id);
$qns->setParameter("pontos", $pontos);


  return $qns->getResult();


}

我在班上有这个属性,但没有orm的注释

我收到一个错误:

  

注意:未定义索引:area_int in   /var/www/incra/vendor/doctrine/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php   第205行

我的班级:http://pastebin.com/jd3gcr93

1 个答案:

答案 0 :(得分:0)

使用executeQuery来使用native而不使用dql