• <tfoot id='FV4oo'></tfoot>

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

          <bdo id='FV4oo'></bdo><ul id='FV4oo'></ul>

      1. <i id='FV4oo'><tr id='FV4oo'><dt id='FV4oo'><q id='FV4oo'><span id='FV4oo'><b id='FV4oo'><form id='FV4oo'><ins id='FV4oo'></ins><ul id='FV4oo'></ul><sub id='FV4oo'></sub></form><legend id='FV4oo'></legend><bdo id='FV4oo'><pre id='FV4oo'><center id='FV4oo'></center></pre></bdo></b><th id='FV4oo'></th></span></q></dt></tr></i><div id='FV4oo'><tfoot id='FV4oo'></tfoot><dl id='FV4oo'><fieldset id='FV4oo'></fieldset></dl></div>
      2. <legend id='FV4oo'><style id='FV4oo'><dir id='FV4oo'><q id='FV4oo'></q></dir></style></legend>
      3. 为什么列别名在学说中不起作用?

        时间:2024-08-09
        <legend id='BRyqf'><style id='BRyqf'><dir id='BRyqf'><q id='BRyqf'></q></dir></style></legend>
            <tbody id='BRyqf'></tbody>

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

              <tfoot id='BRyqf'></tfoot>

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

                  <bdo id='BRyqf'></bdo><ul id='BRyqf'></ul>
                  本文介绍了为什么列别名在学说中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的脚本是这样的:

                  $query = Doctrine_Query::create ()
                    ->select('count(p.product_id) as num_a')              
                    ->from ( 'ProductComments p' )
                    ->groupBy('p.product_id')
                    ->having('num_a =2 ');
                  

                  而生成的sql是:

                  SELECT COUNT(i.product_id) AS i__0 FROM productcomments i GROUP BY i.product_id HAVING num_a=2
                  

                  因此我在执行 sql 时遇到错误.

                  Thus I get an error when execute the sql.

                  我有两个问题:

                  1. 为什么表的别名是'i'而不是'p'?

                  为什么have子句中的'num_a'没有替换成'i__0',如何解决?

                  why is the 'num_a' in having clause not replaced with 'i__0',how to fixed it?

                  感谢您的建议...

                  推荐答案

                  1:为什么表'i'的别名是而不是p"?

                  1: why is the alias of the table 'i' instead of 'p'?

                  2: 为什么是 'num_a'in have 子句不替换为'i__0',如何解决?

                  2: why is the 'num_a' in having clause not replaced with 'i__0',how to fixed it?

                  这两个问题都得到了简单的回答:Doctrine 使用它自己的别名进行查询.您无需知道这些别名,因为它们不会影响您,您也不需要使用它.

                  Both questions are simply answered: Doctrine uses it's own aliases for the query. You do no need to know these aliases since they will not affect you nor will you need to work with it.

                  即使 Doctrine 将别名命名为 i__0,您也可以使用自定义别名访问该属性,例如$yourObject->num_a 将具有正确的值,即 count(p.product_id) 的结果.

                  Even though Doctrine names the alias i__0 you can access the attribute with your custom alias, e.g. $yourObject->num_a will have the proper value, namely the result of count(p.product_id).

                  查看查询的输出是一个有用的调试功能,但依赖应用程序内部是没有意义的,因为这些值仅用于 Doctrine 的内部机制.

                  To see the output of your query is a useful debug feature, but relying on in inside your application is non-sense since these values are only used for the internal mechanisms of Doctrine.

                  这篇关于为什么列别名在学说中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Doctrine 和 Symfony 中的 MySQL 用户定义变量 下一篇:不允许 ResultSetMappingBuilder 工作的原则

                  相关文章

                  1. <i id='cXYc9'><tr id='cXYc9'><dt id='cXYc9'><q id='cXYc9'><span id='cXYc9'><b id='cXYc9'><form id='cXYc9'><ins id='cXYc9'></ins><ul id='cXYc9'></ul><sub id='cXYc9'></sub></form><legend id='cXYc9'></legend><bdo id='cXYc9'><pre id='cXYc9'><center id='cXYc9'></center></pre></bdo></b><th id='cXYc9'></th></span></q></dt></tr></i><div id='cXYc9'><tfoot id='cXYc9'></tfoot><dl id='cXYc9'><fieldset id='cXYc9'></fieldset></dl></div>
                      <bdo id='cXYc9'></bdo><ul id='cXYc9'></ul>
                  2. <small id='cXYc9'></small><noframes id='cXYc9'>

                    <tfoot id='cXYc9'></tfoot>

                    <legend id='cXYc9'><style id='cXYc9'><dir id='cXYc9'><q id='cXYc9'></q></dir></style></legend>