我希望使用使用'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行
答案 0 :(得分:0)
使用executeQuery来使用native而不使用dql