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

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

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

      <tfoot id='rI5z2'></tfoot>
        <bdo id='rI5z2'></bdo><ul id='rI5z2'></ul>
      <legend id='rI5z2'><style id='rI5z2'><dir id='rI5z2'><q id='rI5z2'></q></dir></style></legend>

      1. 如何在 Laravel Eloquent 查詢(或使用查詢生成器)中為

        How to alias a table in Laravel Eloquent queries (or using Query Builder)?(如何在 Laravel Eloquent 查詢(或使用查詢生成器)中為表添加別名?)
      2. <i id='KbtUo'><tr id='KbtUo'><dt id='KbtUo'><q id='KbtUo'><span id='KbtUo'><b id='KbtUo'><form id='KbtUo'><ins id='KbtUo'></ins><ul id='KbtUo'></ul><sub id='KbtUo'></sub></form><legend id='KbtUo'></legend><bdo id='KbtUo'><pre id='KbtUo'><center id='KbtUo'></center></pre></bdo></b><th id='KbtUo'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KbtUo'><tfoot id='KbtUo'></tfoot><dl id='KbtUo'><fieldset id='KbtUo'></fieldset></dl></div>
      3. <legend id='KbtUo'><style id='KbtUo'><dir id='KbtUo'><q id='KbtUo'></q></dir></style></legend>

        <tfoot id='KbtUo'></tfoot>

      4. <small id='KbtUo'></small><noframes id='KbtUo'>

                • <bdo id='KbtUo'></bdo><ul id='KbtUo'></ul>
                    <tbody id='KbtUo'></tbody>
                  本文介紹了如何在 Laravel Eloquent 查詢(或使用查詢生成器)中為表添加別名?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  假設我們正在使用 Laravel 的查詢構建器:

                  $users = DB::table('really_long_table_name')-> 選擇('really_long_table_name.id')->get();

                  我正在尋找與此 SQL 等效的語句:

                  really_long_table_name AS short_name

                  當我必須輸入大量選擇和 wheres(或者通常我在選擇的列別名中也包含別名,并且它在結果數組中使用)時,這將特別有用.如果沒有任何表別名,我就需要打更多的字,而且一切都變得不那么可讀了.在 laravel 文檔中找不到答案,有什么想法嗎?

                  解決方案

                  Laravel 支持使用 AS 為表和列設置別名.試試

                  $users = DB::table('really_long_table_name AS t')->select('t.id AS uid')->get();

                  讓我們用一個很棒的 tinker 工具來看看它的作用

                  <前>$ php 工匠修補匠[1] > Schema::create('really_long_table_name', function($table) {$table->increments('id');});//空值[2] > DB::table('really_long_table_name')->insert(['id' => null]);//真的[3] > DB::table('really_long_table_name AS t')->select('t.id AS uid')->get();//大批(//0 => object(stdClass)(//'uid' => '1'//)//)

                  Lets say we are using Laravel's query builder:

                  $users = DB::table('really_long_table_name')
                             ->select('really_long_table_name.id')
                             ->get();
                  

                  I'm looking for an equivalent to this SQL:

                  really_long_table_name AS short_name
                  

                  This would be especially helpful when I have to type a lot of selects and wheres (or typically I include the alias in the column alias of the select as well, and it get's used in the result array). Without any table aliases there is a lot more typing for me and everything becomes a lot less readable. Can't find the answer in the laravel docs, any ideas?

                  解決方案

                  Laravel supports aliases on tables and columns with AS. Try

                  $users = DB::table('really_long_table_name AS t')
                             ->select('t.id AS uid')
                             ->get();
                  

                  Let's see it in action with an awesome tinker tool

                  $ php artisan tinker
                  [1] > Schema::create('really_long_table_name', function($table) {$table->increments('id');});
                  // NULL
                  [2] > DB::table('really_long_table_name')->insert(['id' => null]);
                  // true
                  [3] > DB::table('really_long_table_name AS t')->select('t.id AS uid')->get();
                  // array(
                  //   0 => object(stdClass)(
                  //     'uid' => '1'
                  //   )
                  // )
                  

                  這篇關于如何在 Laravel 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 找不到驅動程序)
                    • <tfoot id='if0cn'></tfoot>
                        <legend id='if0cn'><style id='if0cn'><dir id='if0cn'><q id='if0cn'></q></dir></style></legend>
                      1. <small id='if0cn'></small><noframes id='if0cn'>

                          <tbody id='if0cn'></tbody>

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

                            主站蜘蛛池模板: 久久精品国产一区二区电影 | 在线四虎| 精品国产一区二区三区日日嗨 | 黄色一级电影在线观看 | www.国产一区| 精品久久久久久亚洲综合网站 | 亚洲精品综合 | 精久久 | 久久国产精品久久久久 | 中文字幕1区 | 日韩一区二区三区在线 | 国产欧美一区二区三区在线看 | 国产精品视频中文字幕 | 久久一级| 欧美日韩在线精品 | 久久久久久久久久久丰满 | 久久精品亚洲欧美日韩精品中文字幕 | 日韩精品一区二区三区视频播放 | 自拍偷拍亚洲视频 | 久久三级av | 欧美精品一区三区 | 国产亚洲日本精品 | 福利社午夜影院 | 玖玖国产 | 精品一二区 | 欧美 日韩 综合 | 97影院在线午夜 | 青青久在线视频 | 国产成人精品网站 | 国产高清视频在线观看 | 国产美女一区 | 91久久久www播放日本观看 | 久久另类视频 | 国产成人福利视频 | 国产特级毛片aaaaaa喷潮 | 中文字幕一区二区三区四区五区 | 国产精品不卡 | 中文字幕精品一区久久久久 | 亚洲自拍偷拍免费视频 | 日韩精品在线网站 | 精品久久香蕉国产线看观看亚洲 |