久久久久久久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 中為列的名稱設(shè)置別名

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

          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 中為列的名稱設(shè)置別名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                I have an eloquent model named Eloquent:

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

                現(xiàn)在我想給它添加join語句,我已經(jīng)定義了一個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
                

                所以在最終結(jié)果數(shù)組中我這樣做:

                So that in the final result array I do :

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

                雖然現(xiàn)在我必須:

                $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();
                

                這篇關(guān)于如何在 Eloquent 中為列的名稱設(shè)置別名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                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 和魔術(shù)方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)

              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>
                        • 主站蜘蛛池模板: 91福利在线观看视频 | 99久久精品一区二区毛片吞精 | 中文字幕不卡在线88 | 黄色国产在线视频 | 激情av在线 | 一区二区三区中文字幕 | 国产亚洲精品久久情网 | 亚洲国产成人精品女人久久久 | 午夜视频在线 | 亚洲欧美日韩电影 | 先锋资源网 | 久久久久久久一区二区三区 | 九九久久精品 | 亚洲一区在线观看视频 | av黄色在线| 91久久北条麻妃一区二区三区 | 日本人麻豆| 毛片在线看片 | 国产成人精品福利 | 麻豆一区二区三区 | 一级在线视频 | 日本视频免费 | 91在线网 | 久草a√| 中文字幕一级 | 国产精品久久久久久久久久久久冷 | 在线观看成人免费视频 | 成人二区三区 | 色在线视频网站 | 天天干夜夜操 | 99热在线播放 | 成人精品视频在线 | 久久精品久久久久久 | 在线观看日韩精品视频 | 中文字幕乱码一区二区三区 | 色av一区二区三区 | 欧美日韩在线一区二区 | 中文字幕在线电影观看 | 精品久久久久久亚洲国产800 | 国产一区二区三区四区 | 国产a区 |