pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    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="e0sm2uw" 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="kcgwy0c" 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="6mage0a" 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'>

                            主站蜘蛛池模板: 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 鑫达滑石-辽宁鑫达滑石集团 | 热处理炉-退火炉-回火炉设备厂家-丹阳市电炉厂有限公司 | TTCMS自助建站_网站建设_自助建站_免费网站_免费建站_天天向上旗下品牌 | 九州网址_专注于提供网址大全分享推广中文网站导航服务 | 沈阳激光机-沈阳喷码机-沈阳光纤激光打标机-沈阳co2激光打标机 | 缠膜机|缠绕包装机|无纺布包装机-济南达伦特机械设备有限公司 | 柔性输送线|柔性链板|齿形链-上海赫勒输送设备有限公司首页[输送机] | 车辆定位管理系统_汽车GPS系统_车载北斗系统 - 朗致物联 | 通用磨耗试验机-QUV耐候试验机|久宏实业百科 | 河北中仪伟创试验仪器有限公司是专业生产沥青,土工,水泥,混凝土等试验仪器的厂家,咨询电话:13373070969 | 1000帧高速摄像机|工业高速相机厂家|科天健光电技术 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 【化妆品备案】进口化妆品备案流程-深圳美尚美化妆品有限公司 | 北京征地律师,征地拆迁律师,专业拆迁律师,北京拆迁律师,征地纠纷律师,征地诉讼律师,征地拆迁补偿,拆迁律师 - 北京凯诺律师事务所 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 外贸资讯网 - 洞悉全球贸易,把握市场先机 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 | 常州减速机_减速机厂家_常州市减速机厂有限公司 | 磁力抛光机_磁力研磨机_磁力去毛刺机_精密五金零件抛光设备厂家-冠古科技 | 发电机组|柴油发电机组-批发,上柴,玉柴,潍柴,康明斯柴油发电机厂家直销 | 不锈钢列管式冷凝器,换热器厂家-无锡飞尔诺环境工程有限公司 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 路面机械厂家| 深圳市超时尚职业培训学校,培训:月嫂,育婴,养老,家政;化妆,美容,美发,美甲. | 桌上式超净工作台-水平送风超净工作台-上海康路仪器设备有限公司 | 郑州爱婴幼师学校_专业幼师培训_托育师培训_幼儿教育培训学校 | 无硅导热垫片-碳纤维导热垫片-导热相变材料厂家-东莞市盛元新材料科技有限公司 | 深圳公司注册-工商注册公司-千百顺代理记账公司 | 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | 通风气楼_通风天窗_屋顶风机-山东美创通风设备有限公司 | 机械立体车库租赁_立体停车设备出租_智能停车场厂家_春华起重 | 贝朗斯动力商城(BRCPOWER.COM) - 买叉车蓄电池上贝朗斯商城,价格更超值,品质有保障! | 北京乾茂兴业科技发展有限公司| 滑石粉,滑石粉厂家,超细滑石粉-莱州圣凯滑石有限公司 | 短信群发平台_群发短信软件_短信营销-讯鸽科技| 苏州西朗门业-欧盟CE|莱茵UL双认证的快速卷帘门品牌厂家 | 细胞染色-流式双标-试剂盒免费代做-上海研谨生物科技有限公司 | 广州印刷厂_广州彩印厂-广州艺彩印务有限公司 |