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

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

  • <tfoot id='GRmmn'></tfoot>
    1. <legend id='GRmmn'><style id='GRmmn'><dir id='GRmmn'><q id='GRmmn'></q></dir></style></legend>

          <bdo id='GRmmn'></bdo><ul id='GRmmn'></ul>
      1. <small id='GRmmn'></small><noframes id='GRmmn'>

        Laravel - 數(shù)據(jù)庫、表和列命名約定?

        Laravel - Database, Table and Column Naming Conventions?(Laravel - 數(shù)據(jù)庫、表和列命名約定?)

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

      2. <tfoot id='R5OGS'></tfoot>

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

                1. 本文介紹了Laravel - 數(shù)據(jù)庫、表和列命名約定?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 laravel eloquent 數(shù)據(jù)對象來訪問我的數(shù)據(jù),為我的表、列、外鍵/主鍵等命名的最佳方式是什么?

                  I'm using laravel eloquent data objects to access my data, what is the best way to name my tables, columns, foreign/primary keys etc?

                  我發(fā)現(xiàn),有很多命名約定.我只是想知道哪一種最適合 Laravel eloquent 模型.

                  I found, there are lots of naming conventions out there. I'm just wondering which one best suits for laravel eloquent models.

                  我正在考慮以下命名約定:

                  I'm thinking of following naming convention:

                  1. 單一的表名(例如:Post)
                  2. 單列名稱(例如:userId - 帖子表中的用戶 ID)
                  3. 表格名稱中多個單詞的駝峰式大小寫(例如:PostComment、PostReview、PostPhoto)
                  4. 列名稱中多個單詞的駝峰式大小寫(例如:firstName、postCategoryId、postPhotoId)

                  因此,我可以在控制器中使用類似的語法.

                  So with this, I could use similar syntax in the controller.

                  $result = Post::where('postCategoryId', '4')->get();
                  

                  是否有任何推薦的 Laravel 指南?我可以繼續(xù)使用這些命名約定嗎?

                  Are there any recommended Laravel guidelines for this? Can I proceed with these naming conventions?

                  如果有人有更好的建議,我會很高興聽到的.非常感謝!

                  If someone has better suggestions, I will be very happy to hear them.Thanks a lot!

                  推薦答案

                  Laravel 有自己的命名約定.例如,如果您的模型名稱是 User.php,那么 Laravel 期望類 'User' 位于該文件中.User 模型還需要 users 表.但是,您可以通過在模型上定義表屬性來覆蓋此約定,例如

                  Laravel has its own naming convention. For example, if your model name is User.php then Laravel expects class 'User' to be inside that file. It also expects users table for User model. However, you can override this convention by defining a table property on your model like,

                      class User extends Eloquent implements UserInterface, RemindableInterface {
                          protected $table = 'user';
                      }
                  

                  來自 Laravel 官方文檔:

                  From Laravel official documentation:

                  請注意,我們沒有告訴 Eloquent 將哪個表用于我們的 User 模型.類的小寫復數(shù)名稱將用作表名除非明確指定另一個名稱.所以,在這種情況下,Eloquent將假設 User 模型將記錄存儲在 users 表中.你可以指定一個通過在模型上定義 $table 屬性來自定義表

                  Note that we did not tell Eloquent which table to use for our User model. The lower-case, plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, Eloquent will assume the User model stores records in the users table. You may specify a custom table by defining a $table property on your model

                  如果您將在另一個表中使用用戶表 id 作為外鍵,那么它應該像 user_id 這樣的蛇形大小寫,以便它可以在關系的情況下自動使用.同樣,您可以通過在關系函數(shù)中指定附加參數(shù)來覆蓋此約定.例如,

                  If you will use user table id in another table as a foreign key then, it should be snake-case like user_id so that it can be used automatically in case of relation. Again, you can override this convention by specifying additional arguments in relationship function. For example,

                      class User extends Eloquent implements UserInterface, RemindableInterface {
                          public function post(){
                              return $this->hasMany('Post', 'userId', 'id');
                          }
                      }
                  
                      class Post extends Eloquent{
                          public function user(){
                              return $this->belongsTo('User', 'userId', 'id');
                          }   
                      }
                  

                  Laravel eloquent關系的文檔

                  對于表中的其他列,您可以隨意命名它們.

                  For other columns in table, you can name them as you like.

                  我建議您瀏覽一次文檔.

                  I suggest you to go through documentation once.

                  這篇關于Laravel - 數(shù)據(jù)庫、表和列命名約定?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(liá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 和魔術方法)
                  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='2Xief'></tfoot>

                    <small id='2Xief'></small><noframes id='2Xief'>

                          <tbody id='2Xief'></tbody>
                        <legend id='2Xief'><style id='2Xief'><dir id='2Xief'><q id='2Xief'></q></dir></style></legend>
                        • <bdo id='2Xief'></bdo><ul id='2Xief'></ul>

                          <i id='2Xief'><tr id='2Xief'><dt id='2Xief'><q id='2Xief'><span id='2Xief'><b id='2Xief'><form id='2Xief'><ins id='2Xief'></ins><ul id='2Xief'></ul><sub id='2Xief'></sub></form><legend id='2Xief'></legend><bdo id='2Xief'><pre id='2Xief'><center id='2Xief'></center></pre></bdo></b><th id='2Xief'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2Xief'><tfoot id='2Xief'></tfoot><dl id='2Xief'><fieldset id='2Xief'></fieldset></dl></div>
                          • 主站蜘蛛池模板: a在线视频| 国产精品久久久久久高潮 | 欧美日韩亚洲系列 | 秋霞在线一区二区 | 一区二区三区精品在线 | 久久久久久久久久一区 | 国产精品久久久久久亚洲调教 | 日韩日韩日韩日韩日韩日韩日韩 | 91精品国产一区二区三区 | 在线欧美日韩 | 成人国产精品免费观看视频 | 香蕉av免费 | 一区二区不卡 | 久久免费精品 | 欧美成年视频 | 中文字幕在线观看一区 | 日韩中文一区 | 台湾av在线| 99久久免费精品国产男女高不卡 | 综合久久久久久久 | 麻豆av在线免费观看 | 国产精品欧美一区二区三区 | 国产欧美精品一区 | 欧美成人不卡 | 性欧美精品一区二区三区在线播放 | 一级在线免费观看 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | 伊人热久久 | 偷拍亚洲色图 | 国产在线精品一区二区三区 | 精品久久久久一区二区国产 | 国产成人av在线 | 午夜在线免费观看 | 国产精品123区 | 日本黄色高清视频 | 国产精品久久久久久久久久久久 | 国产精品久久av | 瑞克和莫蒂第五季在线观看 | jlzzjlzz国产精品久久 | 在线视频第一页 | 国产美女一区二区 |