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

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

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

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

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

        如何在與 Laravel Eloquent 方法 WITH 連接的元素上使

        How to use orderby on element that was joined with Laravel Eloquent method WITH(如何在與 Laravel Eloquent 方法 WITH 連接的元素上使用 orderby)
        <i id='5e9wr'><tr id='5e9wr'><dt id='5e9wr'><q id='5e9wr'><span id='5e9wr'><b id='5e9wr'><form id='5e9wr'><ins id='5e9wr'></ins><ul id='5e9wr'></ul><sub id='5e9wr'></sub></form><legend id='5e9wr'></legend><bdo id='5e9wr'><pre id='5e9wr'><center id='5e9wr'></center></pre></bdo></b><th id='5e9wr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5e9wr'><tfoot id='5e9wr'></tfoot><dl id='5e9wr'><fieldset id='5e9wr'></fieldset></dl></div>
      2. <tfoot id='5e9wr'></tfoot>
      3. <small id='5e9wr'></small><noframes id='5e9wr'>

            <legend id='5e9wr'><style id='5e9wr'><dir id='5e9wr'><q id='5e9wr'></q></dir></style></legend>

              • <bdo id='5e9wr'></bdo><ul id='5e9wr'></ul>
                  <tbody id='5e9wr'></tbody>
                1. 本文介紹了如何在與 Laravel Eloquent 方法 WITH 連接的元素上使用 orderby的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  問題是查詢找不到specific_method(specific_method, specific_model,SpecificModel,specificMethod etc...),應(yīng)該與Laravel Eloquent中的WITH方法連接.任何想法如何解決它?我的代碼:

                  The problem is that the query can't find the specific_method(specific_method, specific_model,SpecificModel,specificMethod etc...), that should been joined with the method WITH from Laravel Eloquent. Any ideas how to solve it? My code:

                  //SpecificModel
                  <?php
                  namespace AppModels;
                  use IlluminateDatabaseEloquentModel;
                  
                  class SpecificModel extends Model {
                  
                      protected $guard_name = 'web';
                      protected $table = 'SpecificTable';
                      protected $guarded = ['id'];
                  
                      public function specificMethod(){
                          return $this->belongsTo('AppModelsAnotherModel','AnotherModel_id');
                      }
                  }
                  
                  
                  //AnotherModel
                  <?php
                  namespace AppModels;
                  use IlluminateDatabaseEloquentModel;
                  
                  class AnotherModel extends Model {
                  
                      protected $guard_name = 'web';
                      protected $table = 'AnotherTable';
                      protected $guarded = ['id'];
                  }
                  
                  //Query method
                  $model = app('AppModelsSpecificModel');
                  $query = $model::with('specificMethod:id,title');
                  $query = $query->orderBy('specific_method.title','desc');
                  return $query->get();
                  
                  
                  //Error
                  Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 
                  '"specific_method.title"' in 'order clause' (SQL: select * from 
                  `SpecificModel` where `SpecificModel`.`deleted_at` is null order by 
                  `specific_method`.`title` desc)
                  

                  推薦答案

                  發(fā)生這種情況是因?yàn)閎elongsTo 關(guān)系沒有像您期望的那樣執(zhí)行join 查詢(正如您從錯(cuò)誤中看到的得到).它執(zhí)行另一個(gè)查詢以獲取相關(guān)模型.因此,您將無法通過相關(guān)模型列訂購原始模型.

                  This happens because the belongsTo relationship does not execute a join query as you expect it to (as you can see from the error you get). It executes another query to get the related model(s). As such you will not be able to order the original model by related models columns.

                  基本上,會(huì)發(fā)生 2 個(gè)查詢:

                  Basically, 2 queries happen:

                  1. 使用 SELECT * from originalModel ...*

                  使用 SELECT * from relatedModel where in id (originalModelForeignKeys)

                  然后 Laravel 做了一些魔術(shù),將第二個(gè)查詢中的模型附加到第一個(gè)查詢中的正確模型上.

                  Then Laravel does some magic and attaches the models from the 2nd query to the correct models from the first query.

                  您需要執(zhí)行實(shí)際的join能夠以您想要的方式訂購.

                  You will need to perform an actual join to be able to order the way you want it to.

                  這篇關(guān)于如何在與 Laravel Eloquent 方法 WITH 連接的元素上使用 orderby的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準(zhǔn)備好的語句amp;foreach 循環(huán))
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個(gè)服務(wù)器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識(shí)別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個(gè)參數(shù))
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結(jié)果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“l(fā)ocalhost的訪問被拒絕)
                2. <tfoot id='ngSJs'></tfoot>
                3. <legend id='ngSJs'><style id='ngSJs'><dir id='ngSJs'><q id='ngSJs'></q></dir></style></legend>
                    <bdo id='ngSJs'></bdo><ul id='ngSJs'></ul>

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

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

                            主站蜘蛛池模板: 欧美精品一区二区三区在线播放 | 亚洲视频中文字幕 | 可以在线观看av的网站 | 国产在线观看网站 | 中文字幕国产一区 | 成人在线欧美 | 国产一区二区电影 | 在线观看黄色 | 日韩欧美中文在线 | 日韩国产在线 | 91久久久久 | 亚洲成人网在线观看 | www.国产.com| 中文字幕一区二区三区四区 | 色婷婷久久综合 | 亚洲91精品 | 国产美女视频黄 | 一级大片免费 | 久久久无码精品亚洲日韩按摩 | 91国产在线视频在线 | 99免费看 | 国产一区二区免费电影 | av黄色在线| 男女视频免费 | 91传媒在线观看 | 国产xxxx岁13xxxxhd | 国产免费看 | 天天久久 | 四虎影院在线免费观看 | 日韩另类视频 | 欧美二区三区 | 亚洲国产精品视频一区 | 日本三级全黄三级三级三级口周 | 久久婷婷香蕉热狠狠综合 | 亚洲精品久久视频 | 一区二区三区四区在线视频 | 欧美激情视频网站 | 成人精品一区二区 | www.久久久久久久久久久 | 最新午夜综合福利视频 | 欧美精品乱码久久久久久按摩 |