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

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

    1. <legend id='81Nvz'><style id='81Nvz'><dir id='81Nvz'><q id='81Nvz'></q></dir></style></legend>

    2. <small id='81Nvz'></small><noframes id='81Nvz'>

        <bdo id='81Nvz'></bdo><ul id='81Nvz'></ul>

    3. <tfoot id='81Nvz'></tfoot>

      如何在 Eloquent 中為列的名稱設置別名

      How to alias the name of a column in Eloquent(如何在 Eloquent 中為列的名稱設置別名)

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

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

              1. 本文介紹了如何在 Eloquent 中為列的名稱設置別名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個名為 Eloquent 的 eloquent 模型:

                I have an eloquent model named Eloquent:

                Products::where("actice", "=", true)->get()->toArray();
                

                現在我想給它添加join語句,我已經定義了一個scopeQuery:

                Now I want to add join-statement to it, I have defined a scopeQuery with:

                public function scopeJoinWithTags($query)
                    {
                        return $query->leftJoin("tags", "tags.id", "=", "products.tag_id");
                    }
                

                然后我們的主要查詢更改為:

                Then our main query changes to:

                Products::where("actice", "=", true)->joinWithTags->get()->toArray();
                

                我得到的沒問題,這正是我所期望的,但我想將標簽表的名稱屬性更改為 tag_name,我該怎么做?我的意思是,我在查詢中的某處說:

                What I get is OK, it is what I do expect, but I want to change the name property of tags table to tag_name, how should I do that? I mean, i say somewhere in my query to:

                 tags.name AS tag_name
                

                所以在最終結果數組中我這樣做:

                So that in the final result array I do :

                $result[$i]['tag_name'];
                

                雖然現在我必須:

                $result[$i]['name'];
                

                推薦答案

                最簡單的方法是將您需要的字段添加到 get() 方法中,并為您想要的字段添加別名在那里重命名.

                Simplest way to do this would be to add the fields you need to the get() method and alias the ones you want to rename there.

                Products::where("actice", "=", true)
                    ->joinWithTags
                    ->get(['tags.name AS tag_name', 'products.*'])
                    ->toArray();
                

                這篇關于如何在 Eloquent 中為列的名稱設置別名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)

              2. <legend id='dB8h0'><style id='dB8h0'><dir id='dB8h0'><q id='dB8h0'></q></dir></style></legend>

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

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

                        <bdo id='dB8h0'></bdo><ul id='dB8h0'></ul>
                        • 主站蜘蛛池模板: 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 | 中文在线视频 | 午夜激情影院 | 性色av一区二区三区 | 精品一二区 | 中文字幕啪啪 | 国产免费麻豆视频 | 日韩精品一区在线观看 | 欧美一二精品 | 欧美日本亚洲 | 中文字幕在线第一页 | 婷婷丁香激情 | 久久精品久久久久久 | 亚洲性视频 | 久久久久久亚洲欧洲 | 久久精品国产亚洲一区二区 | 久久婷婷国产麻豆91 | 99视频免费看| 在线a视频 | 二区三区在线观看 | 日韩欧美国产成人一区二区 | 国产女人与拘做受免费视频 | 免费视频一区二区 | 在线中文视频 | 天堂中文在线观看 | 日本在线视频一区二区 | 国产三级一区二区三区 | 成人午夜视频在线观看 | 午夜小电影| 天天操夜夜拍 | 欧美二区在线 | 91干b| 成人欧美一区二区三区黑人孕妇 | 精品国产乱码久久久久久中文 | 日本一区二区三区免费观看 | 97久久久久久久久 | 欧美国产视频 | 伊人91在线 | 日本一区二区在线视频 | 99视频在线 | 亚洲免费福利视频 |