Doctrine2: Native SQL alias in SELECT
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Default_Model_School', 's');
$rsm->addMetaResult('s', 'distance', 'distance'); // no
$rsm->addFieldResult('s', 'id', 'id');
$rsm->addFieldResult('s', 'establishment_name', 'establishment_name');
$query = $this->_em->createNativeQuery(
'SELECT *, a*b AS distance
FROM schools',
开发者_JAVA技巧 $rsm);
I am trying to get distance out from the query.
I tried the following, which works but breaks my other queries...
$rsm->addMetaResult('s', 'distance', 'distance');
and added the column to my entity...
/**
* @var string $distance
* @Column(type="string")
*/
private $distance;
This does not seem right as the column does not exist.
精彩评论