如何使用带有HYDRATE_ARRAY的doctrine2获得所有结果?

时间:2016-05-06 16:17:49

标签: php doctrine-orm zend-framework2

它怎么样?

所以,我有这个DQL来推送我的数据库的一些寄存器:

$orcamentoEntity = $this->queryBuilder->createQueryBuilder()
                ->select('o', 'c.clientenome', 'c.clienteemail', 'MAX(oa.orcamentoacompanhamentodata) AS dataUltimoAcompanhamento', 'os.orcamentosituacaonome')
                ->from('Admin\Entity\Orcamento', 'o')
                ->leftJoin('Admin\Entity\Cliente', 'c', \Doctrine\ORM\Query\Expr\Join::WITH, 'o.clienteid = c.id')
                ->leftJoin('Admin\Entity\Orcamentoacompanhamento', 'oa', \Doctrine\ORM\Query\Expr\Join::WITH, 'o.id = oa.orcamentoid')
                ->leftJoin('Admin\Entity\Orcamentosituacao', 'os', \Doctrine\ORM\Query\Expr\Join::WITH, 'oa.orcamentosituacaoid = os.id')
                ->orderBy('c.id', 'ASC');
return $orcamentoEntity->getQuery()->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);

结果:

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [id] => 2
                    [orcamentoaniversariantenome] => XXXX
                    [orcamentoaniversarianteidadeacomemorar] => 2
                    [orcamentodatainteresse] => DateTime Object
                        (
                            [date] => 2016-05-15 00:00:00.000000
                            [timezone_type] => 3
                            [timezone] => America/Fortaleza
                        )

                    [orcamentohorario] => DateTime Object
                        (
                            [date] => 1970-01-01 15:00:00.000000
                            [timezone_type] => 3
                            [timezone] => America/Fortaleza
                        )

                    [orcamentonumeroconvidados] => 100
                    [orcamentodatacriacao] => DateTime Object
                        (
                            [date] => 2016-05-02 20:11:08.000000
                            [timezone_type] => 3
                            [timezone] => America/Fortaleza
                        )

                    [orcamentoemail] => 
                )

            [clientenome] => XXX
            [clienteemail] => XXX@XXX.com
            [dataUltimoAcompanhamento] => 2016-05-06
            [orcamentosituacaonome] => Creation
        )

)

如果我只有1个注册,那很好!但是,如何才能将所有结果作为数组得到保湿?

我使用的是ZF2 + Doctrine2。

0 个答案:

没有答案