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

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

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

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

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

        Laravel:讓 Eloquent 創(chuàng)建嵌套 SELECT 的正確方法

        Laravel: Proper way to get Eloquent to create nested SELECT(Laravel:讓 Eloquent 創(chuàng)建嵌套 SELECT 的正確方法)

          <legend id='TBp9t'><style id='TBp9t'><dir id='TBp9t'><q id='TBp9t'></q></dir></style></legend>

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

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

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

                  本文介紹了Laravel:讓 Eloquent 創(chuàng)建嵌套 SELECT 的正確方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我試圖雄辯地生成的查詢是

                  The query I am trying to get eloquent to generate is

                  SELECT *, (SELECT COUNT(comment_id) FROM comment AS c WHERE c.approved=true AND c.blog_fk=b.blog_id) AS comment_count FROM blog AS b
                  

                  這是結(jié)果

                  blog_id |  title            | author       | blog           | image            | tags    | created             | updated             | comment_count
                  --------|-------------------|--------------|----------------|------------------|---------|---------------------|---------------------|--------------
                       21 | A day..           | dsyph3r      | Lorem ipsum... | beach.jpg        | symf... | 2014-12-22 19:14:34 | 2014-12-22 19:14:34 | 2
                       22 | The pool ..       | Zero Cool    | Vestibulum ... | pool_leak.jpg    | pool,.. | 2011-07-23 06:12:33 | 2011-07-23 06:12:33 | 10
                       23 | Misdirection...   | Gabriel      | Lorem ipsum... | misdirection.jpg | misd... | 2011-07-16 16:14:06 | 2011-07-16 16:14:06 | 2
                       24 | The grid ...      | Kevin Flynn  | Lorem commo... | the_grid.jpg     | grid... | 2011-06-02 18:54:12 | 2011-06-02 18:54:12 | 0
                       25 | You're either ... | Gary Winston | Lorem ipsum... | one_or_zero.jpg  | bina... | 2011-04-25 15:34:18 | 2011-04-25 15:34:18 | 2
                  

                  我目前使用 DB::select(DB::raw()) 運行它,這可能不是正確的方法.

                  I currently have this running by using DB::select( DB::raw()) which probably isn't the correct way to do this.

                  問題是什么才是能夠產(chǎn)生這些結(jié)果的查詢的正確方法?

                  The question is what is the proper way to get eloquent to produce the query that generates those results?

                  推薦答案

                  改用這個:http://softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-高效

                  對于嵌套的 select/join 語句,您需要:

                  $sub = Comment::selectRaw('count(comment_id) as count')
                         ->where('approved', '?')
                         ->where('comment.blog_fk', '?')
                         ->toSql();
                  
                  Blog::selectRaw(DB::raw("blog.*, ({$sub}) as comment_count"))
                         ->setBindings([true, DB::raw('blog.blog_id')], 'select')
                         ->get();
                  

                  或者干脆把所有東西都放在selectRaw中.

                  Or simply put everything in selectRaw.

                  這篇關(guān)于Laravel:讓 Eloquent 創(chuàng)建嵌套 SELECT 的正確方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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準(zhǔn)備好的語句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='IKev2'><tr id='IKev2'><dt id='IKev2'><q id='IKev2'><span id='IKev2'><b id='IKev2'><form id='IKev2'><ins id='IKev2'></ins><ul id='IKev2'></ul><sub id='IKev2'></sub></form><legend id='IKev2'></legend><bdo id='IKev2'><pre id='IKev2'><center id='IKev2'></center></pre></bdo></b><th id='IKev2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IKev2'><tfoot id='IKev2'></tfoot><dl id='IKev2'><fieldset id='IKev2'></fieldset></dl></div>
                      <tfoot id='IKev2'></tfoot>
                      <legend id='IKev2'><style id='IKev2'><dir id='IKev2'><q id='IKev2'></q></dir></style></legend>

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

                      • <bdo id='IKev2'></bdo><ul id='IKev2'></ul>
                            <tbody id='IKev2'></tbody>

                          1. 主站蜘蛛池模板: 久久精品黄色 | 丁香色婷婷 | 91精品国产91久久久久久最新 | 中文字幕不卡在线观看 | 久热国产精品视频 | 亚洲协和影视 | 天堂一区在线 | 黄色国产在线播放 | 亚洲福利在线视频 | 一级黄色毛片子 | 国产真实精品久久二三区 | 久久亚洲国产 | 欧美国产精品 | 亚洲视频手机在线 | 亚洲最大的成人网 | 国产精品视频网 | 黑人巨大精品 | 日本久久精品视频 | 国产精品免费一区二区三区 | 亚洲综合日韩精品欧美综合区 | 久久久毛片 | 国产永久免费 | 久久69精品久久久久久国产越南 | 国产精品毛片 | 国产综合网址 | 精品精品 | 日韩电影免费观看中文字幕 | 一区二区三区国产 | 成年人在线视频 | 黄色精品 | 中文字幕在线一区 | 毛片视频观看 | 一级中国毛片 | 一区二区三区中文 | 一级毛片视频 | 亚洲影视在线 | 影音先锋中文字幕在线观看 | 精品成人一区 | 久久久成人免费一区二区 | 伊人狠狠 | 伊人精品 |