久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

      1. 按多列對 Eloquent 集合進行排序的語法是什么?

        What is the syntax for sorting an Eloquent collection by multiple columns?(按多列對 Eloquent 集合進行排序的語法是什么?)
        <legend id='iBhL8'><style id='iBhL8'><dir id='iBhL8'><q id='iBhL8'></q></dir></style></legend>

            <tbody id='iBhL8'></tbody>

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

                • <bdo id='iBhL8'></bdo><ul id='iBhL8'></ul>
                  本文介紹了按多列對 Eloquent 集合進行排序的語法是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我知道在使用查詢構建器時,可以使用

                  I know that when using the query builder, it is possible to sort by multiple columns using

                  ...orderBy('column1')->orderBy('column2')
                  

                  但現在我正在處理一個 collection 對象.集合具有 sortBy 方法,但我無法弄清楚如何使其適用于多列.直覺上,我最初嘗試使用與 orderBy 相同的語法.

                  but now I am dealing with a collection object. Collections have the sortBy method, but I have not been able to figure out how to make it work for multiple columns. Intuitively, I initially tried to use the same syntax as orderBy.

                  sortBy('column1')->sortBy('column2)
                  

                  但這顯然只是按順序應用排序,最終按 column2 排序,而忽略 column1.我試過了

                  but this apparently just applies the sorts sequentially and it ends up sorted by column2, disregarding column1. I tried

                  sortBy('column1', 'column2')
                  

                  但這會引發錯誤asort() 期望參數 2 很長,給出的字符串".使用

                  but that throws the error "asort() expects parameter 2 to be long, string given". Using

                  sortBy('column1, column2')
                  

                  不會拋出錯誤,但排序似乎非常隨機,所以我真的不知道它實際上做了什么.我查看了 sortBy 方法的代碼,但不幸的是我很難理解它是如何工作的.

                  doesn't throw an error, but the sort appears to be pretty random, so I don't really know what that actually does. I looked at the code for the sortBy method, but unfortunately I am having a hard time understanding how it works.

                  推薦答案

                  sortBy() 接受一個閉包,允許您提供一個應該用于排序比較的值,但您可以使它是通過將幾個屬性連接在一起而形成的組合

                  sortBy() takes a closure, allowing you to provide a single value that should be used for sorting comparisons, but you can make it a composite by concatenating several properties together

                  $posts = $posts->sortBy(function($post) {
                      return sprintf('%-12s%s', $post->column1, $post->column2);
                  });
                  

                  如果您需要對多列進行 sortBy,您可能需要對它們進行空格填充以確保ABC"和DEF"出現在AB"和DEF"之后,因此沖刺右填充每列直到列的長度(至少對于除最后一列之外的所有列)

                  If you need the sortBy against multiple columns, you probably need to space pad them to ensure that "ABC" and "DEF" comes after "AB" and "DEF", hence the sprint right padded for each column up to the column's length (at least for all but the last column)

                  請注意,如果您可以在查詢中使用 orderBy,那么通常會更有效率,以便在從數據庫檢索時準備好對集合進行排序

                  Note that it's generally a lot more efficient if you can use an orderBy in your query so the collection is ready-sorted on retrieval from the database

                  這篇關于按多列對 Eloquent 集合進行排序的語法是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  • <tfoot id='TWbBc'></tfoot>

                  • <i id='TWbBc'><tr id='TWbBc'><dt id='TWbBc'><q id='TWbBc'><span id='TWbBc'><b id='TWbBc'><form id='TWbBc'><ins id='TWbBc'></ins><ul id='TWbBc'></ul><sub id='TWbBc'></sub></form><legend id='TWbBc'></legend><bdo id='TWbBc'><pre id='TWbBc'><center id='TWbBc'></center></pre></bdo></b><th id='TWbBc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TWbBc'><tfoot id='TWbBc'></tfoot><dl id='TWbBc'><fieldset id='TWbBc'></fieldset></dl></div>
                    1. <legend id='TWbBc'><style id='TWbBc'><dir id='TWbBc'><q id='TWbBc'></q></dir></style></legend>
                      • <bdo id='TWbBc'></bdo><ul id='TWbBc'></ul>

                          <tbody id='TWbBc'></tbody>

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

                            主站蜘蛛池模板: 亚洲综合一区二区三区 | 久久com| 亚洲国产成人精品久久久国产成人一区 | 性高朝久久久久久久3小时 av一区二区三区四区 | 精品国产乱码久久久久久丨区2区 | 国产精品亚洲视频 | 看毛片的网站 | 国产三区精品 | 久久一久久 | 久草欧美| 成人水多啪啪片 | 亚洲午夜精品一区二区三区 | 国产乱码久久久久久一区二区 | 亚洲欧美一区在线 | 欧美日韩在线精品 | 亚洲网视频| 亚洲一区二区三区在线视频 | 国产精品视频二区三区 | 国产三区四区 | 精品九九九 | 自拍偷拍亚洲欧美 | 亚洲第一网站 | 久久久国产一区二区三区四区小说 | 欧美福利网站 | 91玖玖| www.4567| 免费看国产一级特黄aaaa大片 | 久久草在线视频 | 欧美精品久久 | 国产美女黄色片 | 天天干干| 日本视频中文字幕 | 国产激情网站 | 黄色片视频 | 国产日韩欧美精品一区二区 | 精品久久久久久久人人人人传媒 | 国产资源网 | 欧产日产国产精品国产 | 成人免费一区二区三区牛牛 | 日韩五月天| 国产一级电影在线观看 |