<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

      Return array, not object from Doctrine query - Symfony2(返回数组,而不是来自 Doctrine 查询的对象 - Symfony2)
          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tbody id='J1gOs'></tbody>
                1. <small id='J1gOs'></small><noframes id='J1gOs'>

                    <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>

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