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

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

      <bdo id='hKQjx'></bdo><ul id='hKQjx'></ul>

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

    1. <tfoot id='hKQjx'></tfoot>

        Laravel Eloquent/Query Builder 中 LEFT JOIN 的 ON 子句中的

        Parameterized query binding in ON clause for a LEFT JOIN in Laravel Eloquent / Query Builder(Laravel Eloquent/Query Builder 中 LEFT JOIN 的 ON 子句中的參數(shù)化查詢綁定)
            <bdo id='Q2vh0'></bdo><ul id='Q2vh0'></ul>
          • <i id='Q2vh0'><tr id='Q2vh0'><dt id='Q2vh0'><q id='Q2vh0'><span id='Q2vh0'><b id='Q2vh0'><form id='Q2vh0'><ins id='Q2vh0'></ins><ul id='Q2vh0'></ul><sub id='Q2vh0'></sub></form><legend id='Q2vh0'></legend><bdo id='Q2vh0'><pre id='Q2vh0'><center id='Q2vh0'></center></pre></bdo></b><th id='Q2vh0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Q2vh0'><tfoot id='Q2vh0'></tfoot><dl id='Q2vh0'><fieldset id='Q2vh0'></fieldset></dl></div>

                  <tbody id='Q2vh0'></tbody>

                1. <small id='Q2vh0'></small><noframes id='Q2vh0'>

                2. <tfoot id='Q2vh0'></tfoot>
                  <legend id='Q2vh0'><style id='Q2vh0'><dir id='Q2vh0'><q id='Q2vh0'></q></dir></style></legend>
                3. 本文介紹了Laravel Eloquent/Query Builder 中 LEFT JOIN 的 ON 子句中的參數(shù)化查詢綁定的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  假設(shè)我想顯示 type="color" 的完整獎項列表:

                  Let's say I want to show a full list of awards with type="color":

                  Awards        Type     2013 Winner
                  ======        ====     ===========
                  Blue Award    color       Tom
                  Red Award     color
                  Green Award   color       Dan  
                  

                  為了達到這個結(jié)果,我可以在 Laravel 中進行這樣的查詢:

                  To achieve this result I could have a query in Laravel like this:

                  $year = '2013';
                  
                  $awards = DB::table('awards')
                               ->leftJoin('winners', function($join) use ($year)
                                     {
                                          $join->on('awards.id','=','winners.award_id');
                                          $join->on('winners.year','=',DB::raw("'".$year."'"));
                                     }
                               ->where('awards.type','color')
                               ->get();
                  

                  如果您輸出 Laravel 生成的 SQL,您將看到只有 WHERE 子句 被參數(shù)化,并且 ON 子句 中的 $year 容易受到 sql 注入,如果我從不受信任的來源獲取它.此外,查詢的緩存潛力也會降低,因為 $year 會經(jīng)常更改.注意:如果您認為我只是將第二個左連接條件添加到查詢的 WHERE,這些不一樣.

                  If you output the SQL that Laravel generates you will see that only the WHERE clause is parameterized and $year in the ON clause is left vulnerable to sql injection if I get it from an untrusted source. Also the query's caching potential is reduced because $year will change often. Note: In case you were thinking that I just add the second left join condition to the WHERE of the query, these are not the same.

                  關(guān)于如何將查詢的 $year 部分參數(shù)化有什么想法嗎?

                  Any ideas on how to get the $year part of the query parameterized?

                  推薦答案

                  這里有一個奇怪的解決方法(不想擴展 Builder 和 JoinClause 類):
                  注意:這會破壞 -> 的查詢鏈,所以請注意 where 在下面被分隔.

                  Here's an odd work-around (didn't want to extend the Builder and JoinClause classes):
                  Notice: This will break query chaining with -> so notice the where was seperated below.

                  $query = DB::table('awards')
                           ->leftJoin('winners', function($join)
                                 {
                                      $join->on('awards.id','=','winners.award_id');
                                      $join->on('winners.year','=',DB::raw('?'));  
                                 }
                           ->setBindings(array_merge($query->getBindings(),array($year)));
                  
                  $query->where('awards.type','color');
                  
                  $awards = $query->get();
                  

                  更新:泰勒添加 joinWhere, leftJoinWhere... 他說如果你有一個函數(shù)連接,只需使用 ->where->orWhere從封閉內(nèi)."不過我還沒有嘗試過.

                  UPDATE: Taylor added joinWhere, leftJoinWhere... he says that "if you have a function join just use ->where and ->orWhere from within the Closure." I've yet to try this though.

                  這篇關(guān)于Laravel Eloquent/Query Builder 中 LEFT JOIN 的 ON 子句中的參數(shù)化查詢綁定的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環(huán))
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務(wù)器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數(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的訪問被拒絕)
                  <i id='Ig76s'><tr id='Ig76s'><dt id='Ig76s'><q id='Ig76s'><span id='Ig76s'><b id='Ig76s'><form id='Ig76s'><ins id='Ig76s'></ins><ul id='Ig76s'></ul><sub id='Ig76s'></sub></form><legend id='Ig76s'></legend><bdo id='Ig76s'><pre id='Ig76s'><center id='Ig76s'></center></pre></bdo></b><th id='Ig76s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ig76s'><tfoot id='Ig76s'></tfoot><dl id='Ig76s'><fieldset id='Ig76s'></fieldset></dl></div>

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

                  • <legend id='Ig76s'><style id='Ig76s'><dir id='Ig76s'><q id='Ig76s'></q></dir></style></legend>

                      1. <tfoot id='Ig76s'></tfoot>

                            <tbody id='Ig76s'></tbody>
                            <bdo id='Ig76s'></bdo><ul id='Ig76s'></ul>
                          • 主站蜘蛛池模板: 91免费版在线观看 | 一区二区三区日韩精品 | 99reav| 欧美精品区 | 九九精品在线 | 国产欧美一级二级三级在线视频 | 午夜视频精品 | 亚洲欧美一区二区三区国产精品 | 久久天天躁狠狠躁夜夜躁2014 | 欧美成年网站 | 免费的黄色片子 | 日本午夜一区 | 成人h视频| 久久青| 日日艹夜夜艹 | 色接久久| 日韩在线视频精品 | 97精品超碰一区二区三区 | 日日骚网 | 国产视频h | 欧美亚洲视频在线观看 | 日韩av免费看 | 国产精品区二区三区日本 | 日韩在线精品 | www.色婷婷 | 午夜在线观看视频 | 国产精品成人一区二区三区 | 日韩精品一区二区三区视频播放 | 久热国产精品视频 | 亚洲精品国产一区 | 精品无码久久久久国产 | 午夜精品一区二区三区在线视频 | 色婷婷亚洲国产女人的天堂 | 国产精品99久久久久久久vr | 日韩精品在线一区 | 高清久久久| 亚洲欧洲在线观看视频 | 欧美一区二区三区精品免费 | 欧美精品在线免费观看 | 在线免费看黄 | 一区二区三区在线看 |