1. <tfoot id='Lkbay'></tfoot>

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

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

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

        • <bdo id='Lkbay'></bdo><ul id='Lkbay'></ul>
      1. 如何在 Zend 框架中使用 GROUP_CONCAT?

        时间:2023-10-02

        <tfoot id='4Q8ay'></tfoot>

      2. <small id='4Q8ay'></small><noframes id='4Q8ay'>

              <bdo id='4Q8ay'></bdo><ul id='4Q8ay'></ul>
            • <i id='4Q8ay'><tr id='4Q8ay'><dt id='4Q8ay'><q id='4Q8ay'><span id='4Q8ay'><b id='4Q8ay'><form id='4Q8ay'><ins id='4Q8ay'></ins><ul id='4Q8ay'></ul><sub id='4Q8ay'></sub></form><legend id='4Q8ay'></legend><bdo id='4Q8ay'><pre id='4Q8ay'><center id='4Q8ay'></center></pre></bdo></b><th id='4Q8ay'></th></span></q></dt></tr></i><div id='4Q8ay'><tfoot id='4Q8ay'></tfoot><dl id='4Q8ay'><fieldset id='4Q8ay'></fieldset></dl></div>
            • <legend id='4Q8ay'><style id='4Q8ay'><dir id='4Q8ay'><q id='4Q8ay'></q></dir></style></legend>
                  <tbody id='4Q8ay'></tbody>
                  本文介绍了如何在 Zend 框架中使用 GROUP_CONCAT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  假设我有一张桌子:学生

                  Assume that I have a table : students

                  ______________________________________________________
                  |id   | name           | school        | class        |
                  ______________________________________________________
                  | 1   | John           | ABC           | C1           |
                  | 2   | Jack           | ABC           | C1           |
                  | 3   | Anna           | ABC           | C1           |
                  | 4   | Peter          | DEF           | D1           |
                  | 5   | Alex           | ABC           | C2           |
                  | 6   | Bryan          | ABC           | C2           |
                  | 7   | David          | ABC           | C2           |
                  | 8   | Cristian       | DEF           | D1           |
                  _______________________________________________________
                  

                  使用此查询:

                   SELECT a.class,GROUP_CONCAT(a.name) as names FROM students a WHERE a.school='ABC' GROUP BY a.class 
                  

                  给我这个结果:

                   ____________________________
                  |class  | names             |
                   ____________________________
                  | C1    | John, Jack, Anna  |
                  | C2    | Alex, Bryan, David|
                   ____________________________
                  

                  如何在 Zend Framework 中使用 Zend_Db_Table 或 Zend_Db_Select 执行此查询?非常感谢!

                  How can I execute this query in Zend Framework by using Zend_Db_Table or Zend_Db_Select? Thank you so much!

                  推荐答案

                  我想它会是这样的.试试吧.

                  I guess it will be something like this. Try it.

                  $table = Your_DbTable_Class();
                  $select = $table->select()
                            ->setIntegrityCheck(false)
                            ->from(array('a' => 'students'), array( 'class' => 'class' , 'names' => new Zend_Db_Expr('GROUP_CONCAT(a.name)')) )
                            ->where( 'a.school = ?', 'ABC' ) 
                            ->group('a.class');
                  

                  当我组装它时,它给了我以下查询:

                  When I assemble it, it gives me following query:

                  SELECT `a`.`class`, GROUP_CONCAT(a.name) AS `names` FROM `students` AS `a` 
                  WHERE (a.school = 'ABC')
                  GROUP BY `a`.`class`
                  

                  这是您要找的吗?

                  这篇关于如何在 Zend 框架中使用 GROUP_CONCAT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Zend 框架安全地运行 Cron 作业 下一篇:Linux 上的 PHP 5.4:如何连接 MS SQL Server 2008?

                  相关文章

                  最新文章

                • <tfoot id='TGSmO'></tfoot>
                      <bdo id='TGSmO'></bdo><ul id='TGSmO'></ul>
                  1. <legend id='TGSmO'><style id='TGSmO'><dir id='TGSmO'><q id='TGSmO'></q></dir></style></legend>

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

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