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

<tfoot id='Qzemc'></tfoot>

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

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

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

        Laravel 在 withCount 方法上使用 where 子句

        Laravel using where clause on a withCount method(Laravel 在 withCount 方法上使用 where 子句)
          <legend id='KjlbL'><style id='KjlbL'><dir id='KjlbL'><q id='KjlbL'></q></dir></style></legend>

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

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

              <tbody id='KjlbL'></tbody>

                  <bdo id='KjlbL'></bdo><ul id='KjlbL'></ul>
                • <tfoot id='KjlbL'></tfoot>
                  本文介紹了Laravel 在 withCount 方法上使用 where 子句的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試使用這段代碼對 laravel 的 eloquent 查詢構建器的 withCount 方法執行 where 子句.

                  I am trying to do a where clause on withCount method of laravel's eloquent query builder using this piece of code.

                  $posts = Post::withCount('upvotes')->where('upvotes_count', '>', 5)->get();
                  

                  這段代碼給了我這個錯誤.

                  and this code is giving me this error.

                  SQLSTATE[42S22]:未找到列:1054 未知列upvotes_count"在where 子句"(SQL:select , (select count() from upvotes whereupvotes.upvoteable_id = posts.idupvotes.upvoteable_type = AppPost) as upvotes_count from posts where upvotes_count > 5)

                  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'upvotes_count' in 'where clause' (SQL: select , (select count() from upvotes where upvotes.upvoteable_id = posts.id and upvotes.upvoteable_type = AppPost) as upvotes_count from posts where upvotes_count > 5)

                  所以我可以猜測的是 upvotes_count 沒有被選中,因此沒有找到該列,但是如果我執行這段代碼.

                  So from what I can guess is that upvotes_count isn't selected and hence the column is not being found, BUT if I execute this piece of code.

                  $posts = Post::withCount('upvotes')->get();
                  

                  然后我得到這個輸出.

                  {
                  "id": 1,
                  "user_id": 15,
                  "title": "Voluptatum voluptas sint delectus unde amet quis.",
                  "created_at": "2016-10-07 13:47:48",
                  "updated_at": "2016-10-07 13:47:48",
                  "upvotes_count": 7
                  },
                  {
                  "id": 2,
                  "user_id": 2,
                  "title": "Molestiae in labore qui atque.",
                  "created_at": "2016-10-07 13:47:48",
                  "updated_at": "2016-10-07 13:47:48",
                  "upvotes_count": 2
                  },
                  

                  這基本上意味著 upvotes_count 被選中,因此我真的很困惑如何解決這個問題.

                  Which basically means that upvotes_count is being selected, hence i am really confused about how to solve this problem.

                  (下面給出了我迄今為止嘗試過的更多選項以及與之相關的相應錯誤.)

                  (More options that I tried so far are given below with the respective error associated to it.)

                  $posts = Post::where('id', $id)->withCount(['upvotes' => function($query) {
                          $query->where('upvotes_count', '>', 5);
                      }])->get();
                  

                  錯誤.

                  SQLSTATE[42S22]: Column not found: 1247 Reference 'upvotes_count' not supported (forward reference in item list) (SQL: select , (select count() from upvotes where upvotes.upvoteable_id = posts.id and upvotes.upvoteable_type = AppPost and upvotes_count > 5) as upvotes_count from posts where id =1)

                  SQLSTATE[42S22]: Column not found: 1247 Reference 'upvotes_count' not supported (forward reference in item list) (SQL: select , (select count() from upvotes where upvotes.upvoteable_id = posts.id and upvotes.upvoteable_type = AppPost and upvotes_count > 5) as upvotes_count from posts where id = 1)

                  代碼.

                  $posts = Post::where('id', $id)->with(['upvotes' => function($query) {
                          $query->select('upvoteable_id AS upvotes_count');
                      }])->where('upvotes_count', '>', 5)->get();
                  

                  $posts = AppPost::where('id', $id)->with(['upvotes' => function($query) {
                          $query->selectRaw('upvoteable_id AS upvotes_count');
                      }])->where('upvotes_count', '>', 5)->get();
                  

                  錯誤.

                  SQLSTATE[42S22]:未找到列:1054 Unknown column 'upvotes_count' in 'where clause'(SQL:從 posts 中選擇 * 其中 id = 1 和 <代碼>upvotes_count > 5)

                  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'upvotes_count' in 'where clause' (SQL: select * from posts where id = 1 and upvotes_count > 5)

                  <小時>

                  我只想在與父模型有關系的 count() 方法上使用 where 子句.


                  I just want to use where clause on a count() method which is in a relationship with a parent model.

                  推薦答案

                  您可以通過使用:

                  $posts = Post::withCount('upvotes')
                           ->having('upvotes_count', '>', 5)
                           ->get();
                  

                  這篇關于Laravel 在 withCount 方法上使用 where 子句的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                  <i id='fcS9Q'><tr id='fcS9Q'><dt id='fcS9Q'><q id='fcS9Q'><span id='fcS9Q'><b id='fcS9Q'><form id='fcS9Q'><ins id='fcS9Q'></ins><ul id='fcS9Q'></ul><sub id='fcS9Q'></sub></form><legend id='fcS9Q'></legend><bdo id='fcS9Q'><pre id='fcS9Q'><center id='fcS9Q'></center></pre></bdo></b><th id='fcS9Q'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fcS9Q'><tfoot id='fcS9Q'></tfoot><dl id='fcS9Q'><fieldset id='fcS9Q'></fieldset></dl></div>

                        <bdo id='fcS9Q'></bdo><ul id='fcS9Q'></ul>
                        • <legend id='fcS9Q'><style id='fcS9Q'><dir id='fcS9Q'><q id='fcS9Q'></q></dir></style></legend>

                            <tbody id='fcS9Q'></tbody>
                          <tfoot id='fcS9Q'></tfoot>
                        • <small id='fcS9Q'></small><noframes id='fcS9Q'>

                            主站蜘蛛池模板: www..com18午夜观看 | 亚洲网站在线播放 | 一区在线播放 | 亚洲视频中文字幕 | 精品综合网 | 久久久做 | 最新中文字幕在线播放 | 国产精品美女久久久 | 激情欧美一区二区三区中文字幕 | 欧美成年网站 | 国产在视频一区二区三区吞精 | 欧美一二三区 | 国产成人精品一区二三区在线观看 | 日韩av一区在线观看 | 天天舔天天 | 日韩一区二 | 91人人看| 欧美 中文字幕 | 精品国产一区二区三区久久久久久 | 亚洲中国字幕 | 亚洲精品中文在线观看 | 一区二区三区四区不卡 | 色资源在线视频 | 国产精品视频在线免费观看 | 久久69精品久久久久久国产越南 | 亚洲一区 中文字幕 | www.av在线| 精品免费视频 | 日日夜夜精品免费视频 | 三级免费网| 国产精品久久久久久久久久东京 | 欧美一级免费片 | 国产综合网址 | 网站国产| 91社区在线观看高清 | 欧美精品1区 | 九一精品 | 国产精品高潮呻吟久久aⅴ码 | 日韩成人一区二区 | 久久久久久久综合色一本 | 久久久99精品免费观看 |