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

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

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

        在 yii2 中使用限制范围?

        时间:2023-08-17
          <tbody id='dNgYh'></tbody>
        • <small id='dNgYh'></small><noframes id='dNgYh'>

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

                1. 本文介绍了在 yii2 中使用限制范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想使用 limit 12,20 从数据库获取数据.

                  I want to get data from db using limit 12,20 .

                  这是我的代码:

                    $Query = new Query;
                     $Query->select(['um.id as USERid', 'um.first_name', 'um.last_name',   'um.email', 'COUNT(g.id) as guestCount'])
                   ->from('user_master um')
                   ->join('LEFT JOIN', 'guest g', 'g.user_id = um.id')
                   ->limit(12,20)
                   ->groupBy('um.id')
                   ->orderBy(['um.id' => SORT_DESC]);
                  
                    $command = $Query->createCommand();
                    $evevtsUserDetail = $command->queryAll(); 
                  

                  它不起作用.它给了我所有的行.我也试过 ->limit([12,20]),没有用.

                  It is not working. It is giving me all rows. I also tried ->limit([12,20]), not working.

                  但是当我使用 limit(12) 时,我得到了 12 行.

                  But when I am using limit(12) then I am getting 12 rows.

                  我想在 limit 12,20 中获取行.在我的这段代码中,我应该怎么做?

                  I want to get rows in limit 12,20 . What should I have to do for that in my this code?

                  推荐答案

                  试试这个:

                  $Query = new Query;
                  $Query->select(['um.id as USERid', 'um.first_name', 'um.last_name','um.email','COUNT(g.id) as guestCount'])
                  ->from('user_master um')
                  ->join('LEFT JOIN', 'guest g', 'g.user_id = um.id')
                  ->limit(20)
                  ->offset(12)
                  ->groupBy('um.id')
                  ->orderBy(['um.id' => SORT_DESC]);
                  

                  Offset() 指定起始点,limit() 指定记录数.如果您想要 1220 之间的记录,请使用 limit(8).

                  Offset() specifies the starting point and limit() specifies the Number of records. If you want records between 12 and 20 then use limit(8).

                  更多信息:

                  • http://www.bsourcecode.com/yiiframework2/select-query-模型/#offset
                  • http://www.yiiframework.com/doc-2.0/yii-db-querytrait.html#offset%28%29-detail

                  这篇关于在 yii2 中使用限制范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Yii - 如何打印 findAll 使用的 SQL 下一篇:gii 不在 yii 中工作

                  相关文章

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

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

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