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

  • <legend id='gZYbo'><style id='gZYbo'><dir id='gZYbo'><q id='gZYbo'></q></dir></style></legend>
  • <tfoot id='gZYbo'></tfoot>

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

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

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

        Laravel 5 雄辯的 whereIn

        Laravel 5 eloquent whereIn(Laravel 5 雄辯的 whereIn)

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

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

              <tbody id='zxIr6'></tbody>
            • <tfoot id='zxIr6'></tfoot>

                • 本文介紹了Laravel 5 雄辯的 whereIn的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  希望有人能幫助我,我需要在數據庫中搜索類別 id = x 的項目

                  Hope anybody can help me, I need to search for items that have category id = x in the database

                  示例表格項目id,貓,姓名等...貓 = '1,19' 或者可能只是 '19' 或者可能是 '1,9'

                  Example table items id,cats,name etc... cats = '1,19' or maybe just '19' or maybe '1,9'

                  所以對于這個例子,我需要搜索帶有 9 的貓的項目

                  So for this example I need a to search for items that have cats with 9

                  我試過了,但是當我搜索 9 時,它也顯示了 19

                  I tried this but when I search for 9 it also shows 19

                  $items = Items::where(function($query)use($cat) {
                      $query->where('cats', 'like', '%,'.$cat->id.'%');
                      $query->orWhere('cats', 'like', '%'.$cat->id.',%');
                      $query->orWhere('cats', 'like', '%'.$cat->id.'%');
                      })->orderBy('updated_at', 'DSC')->get();
                  

                  我也嘗試了一些東西

                  $items = Items::whereIn(explode(',', 'cats'), $cat->id)->get(); 
                  

                  但它不起作用

                  感謝任何幫助找到最簡單和簡短的方法,問候

                  Appreciate any help to find the easiest and shorts way of doing this, regards

                  推薦答案

                  很難理解您想要實現的目標,但我會嘗試.首先,正如@particus 提到的,最好的方法是在您不需要擔心此類事情時創建數據透視表.

                  It's quite hard to understand what you want to achieve but I'll try. First of all as @particus mentioned the best way is to create pivot table when you don't need to worry about such things.

                  但是如果您在以昏迷分隔的列中有 id 列表的解決方案不是存儲像

                  But the solution if you have list of ids in a columns separated by coma is not storing values like

                  1,2,3
                  

                  但總是在開頭和結尾添加,,所以在這種情況下應該是:

                  but always adding , at the beginning and at the end, so it should be in this case:

                  ,1,2,3,
                  

                  這樣,如果你的表中有 ,19,2,3, 并且你想搜索值 9,你應該使用查找 ,9, 字符串,例如:

                  This way, if you have in your table ,19,2,3, and you want to search for value 9, you should use look for ,9, string, for example:

                  $id = 9; 
                  $items = Items::where('column', LIKE '%,'.$id.',%')->get();
                  

                  現在對于上面的字符串,不會找到任何記錄,但是如果您有 ,9,2,3, 或只有 ,9, 將找到所需的記錄.

                  Now for above string no record will be found, but if you have ,9,2,3, or just ,9, the desired record will be found.

                  這篇關于Laravel 5 雄辯的 whereIn的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

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

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

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

                          <tfoot id='Ogq3S'></tfoot>

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

                              <tbody id='Ogq3S'></tbody>
                            主站蜘蛛池模板: 午夜男人的天堂 | 国产丝袜一区二区三区免费视频 | 久久国产秒 | 一区二区在线免费观看视频 | 国产99免费视频 | 国产精品福利在线观看 | 欧美综合国产精品久久丁香 | 精品www| 黄色一级免费观看 | 99久久婷婷国产综合精品电影 | 殴美成人在线视频 | 一级黄片一级毛片 | 免费高清av | 青青青伊人 | 午夜在线精品偷拍 | 午夜精品一区二区三区在线视频 | 欧美日韩黄色一级片 | xxx.在线观看 | 久久国产精彩视频 | 国产精品亚洲精品日韩已方 | 国产精品国产精品 | 亚洲三级av | 国产精品久久久久一区二区三区 | 国产久 | 91影院在线观看 | 一区二区三区久久 | 天天在线操 | 国产一级片久久久 | 欧美一区二区三区在线观看 | 久久不射电影网 | 国产一区二区在线视频 | 欧美在线一区二区三区 | 日韩黄a| 亚洲成人黄色 | 一级黄色毛片 | 九九免费视频 | 日韩在线中文 | 免费黄色成人 | 91极品尤物在线播放国产 | 精品久久久一区二区 | 97人人澡人人爽91综合色 |