<tfoot id='GTsH9'></tfoot>

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

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

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

    2. <legend id='GTsH9'><style id='GTsH9'><dir id='GTsH9'><q id='GTsH9'></q></dir></style></legend>
    3. 如何在 Zend 框架中使用 GROUP_CONCAT?

      时间:2023-05-30

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

              <legend id='uepkB'><style id='uepkB'><dir id='uepkB'><q id='uepkB'></q></dir></style></legend>
                <tbody id='uepkB'></tbody>
            1. <small id='uepkB'></small><noframes id='uepkB'>

              • 本文介绍了如何在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文章

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

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

                    <legend id='jADX1'><style id='jADX1'><dir id='jADX1'><q id='jADX1'></q></dir></style></legend>
                    • <bdo id='jADX1'></bdo><ul id='jADX1'></ul>