在Doctrine中使用ResultSetMapping

时间:2015-01-14 06:03:56

标签: php mysql doctrine-orm

我有这样的查询:

  $query = "select run_record_detail.id from
            (select max(id) as run_record_id from run_record  where delete_flag=0 group    by test_run_id) rr
               inner join 
            run_record_detail
            on rr.run_record_id = rr.run_record_id
            where delete_flag=0 and test_case_id IN (:ids)";

    $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
    $rsm->addEntityResult('\Test\Entity\RunRecordDetail', 'run_record_detail');
    $rsm->addFieldResult('run_record_detail', 'id', 'id');
    $query = $this->getEntityManager()->createNativeQuery($query, $rsm);
    $query->setParameter('ids', $testCaseIdArray);
    $result = $query->getResult();

我正在尝试使用ResultsetMapping将run_record_detail绑定到RunRecordDetail对象。我想在输出中使用RunRecordDetail对象。但我只得到它的身份(正如我所选)。请帮我拿到这个对象。 我正在关注Doctrine doc http://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html

0 个答案:

没有答案