<legend id='ns84O'><style id='ns84O'><dir id='ns84O'><q id='ns84O'></q></dir></style></legend>
<i id='ns84O'><tr id='ns84O'><dt id='ns84O'><q id='ns84O'><span id='ns84O'><b id='ns84O'><form id='ns84O'><ins id='ns84O'></ins><ul id='ns84O'></ul><sub id='ns84O'></sub></form><legend id='ns84O'></legend><bdo id='ns84O'><pre id='ns84O'><center id='ns84O'></center></pre></bdo></b><th id='ns84O'></th></span></q></dt></tr></i><div id='ns84O'><tfoot id='ns84O'></tfoot><dl id='ns84O'><fieldset id='ns84O'></fieldset></dl></div>

<small id='ns84O'></small><noframes id='ns84O'>

<tfoot id='ns84O'></tfoot>
      <bdo id='ns84O'></bdo><ul id='ns84O'></ul>
    1. 返回数组,而不是来自 Doctrine 查询的对象 - Symfony2

      时间:2024-08-15
          <tbody id='V2Oyi'></tbody>

        1. <small id='V2Oyi'></small><noframes id='V2Oyi'>

            • <bdo id='V2Oyi'></bdo><ul id='V2Oyi'></ul>

                <tfoot id='V2Oyi'></tfoot>

              • <legend id='V2Oyi'><style id='V2Oyi'><dir id='V2Oyi'><q id='V2Oyi'></q></dir></style></legend>

                <i id='V2Oyi'><tr id='V2Oyi'><dt id='V2Oyi'><q id='V2Oyi'><span id='V2Oyi'><b id='V2Oyi'><form id='V2Oyi'><ins id='V2Oyi'></ins><ul id='V2Oyi'></ul><sub id='V2Oyi'></sub></form><legend id='V2Oyi'></legend><bdo id='V2Oyi'><pre id='V2Oyi'><center id='V2Oyi'></center></pre></bdo></b><th id='V2Oyi'></th></span></q></dt></tr></i><div id='V2Oyi'><tfoot id='V2Oyi'></tfoot><dl id='V2Oyi'><fieldset id='V2Oyi'></fieldset></dl></div>
              • 本文介绍了返回数组,而不是来自 Doctrine 查询的对象 - Symfony2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用这个:

                $this->getDoctrine()->getRepository('MyBundle:MyEntity')->findAll(array(), Query::HYDRATE_ARRAY);
                

                我认为应该确保它返回一个数组的数组,但它仍然返回一个对象数组.

                I thought that should ensure it returns an array of an array, but it still returns an array of objects.

                我需要将整个结果作为数组的数组返回,这样我就可以做这种事情(愚蠢的例子,但它解释了我的意思):

                I need the whole result returned as an array of an array so I can do this kind of thing (silly example, but it explains what I mean):

                <?php
                $result = $this->getDoctrine()->getRepository('MyBundle:MyEntity')->findAll('return-an-array');
                ?>    
                This is the age of the person at the 5th record: <?php echo $result[4]['age']; ?>
                

                推荐答案

                根据这个EntityRepository 类,findAll 不接受多个参数.

                According to this EntityRepository class, findAll don't take multiple arguments.

                下面的代码应该做你想做的事

                The code below should do what you want

                $result = $this->getDoctrine()
                               ->getRepository('MyBundle:MyEntity')
                               ->createQueryBuilder('e')
                               ->select('e')
                               ->getQuery()
                               ->getResult(DoctrineORMQuery::HYDRATE_ARRAY);
                

                这篇关于返回数组,而不是来自 Doctrine 查询的对象 - Symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用教义创建一对多的多态关系 下一篇:symfony 2:命名空间“Acme"不包含任何映射实体

                相关文章

                1. <small id='J1gOs'></small><noframes id='J1gOs'>

                2. <tfoot id='J1gOs'></tfoot>

                    • <bdo id='J1gOs'></bdo><ul id='J1gOs'></ul>

                    <i id='J1gOs'><tr id='J1gOs'><dt id='J1gOs'><q id='J1gOs'><span id='J1gOs'><b id='J1gOs'><form id='J1gOs'><ins id='J1gOs'></ins><ul id='J1gOs'></ul><sub id='J1gOs'></sub></form><legend id='J1gOs'></legend><bdo id='J1gOs'><pre id='J1gOs'><center id='J1gOs'></center></pre></bdo></b><th id='J1gOs'></th></span></q></dt></tr></i><div id='J1gOs'><tfoot id='J1gOs'></tfoot><dl id='J1gOs'><fieldset id='J1gOs'></fieldset></dl></div>

                  1. <legend id='J1gOs'><style id='J1gOs'><dir id='J1gOs'><q id='J1gOs'></q></dir></style></legend>