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

  • <small id='QnZON'></small><noframes id='QnZON'>

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

    1. <tfoot id='QnZON'></tfoot>
      <legend id='QnZON'><style id='QnZON'><dir id='QnZON'><q id='QnZON'></q></dir></style></legend>
          <bdo id='QnZON'></bdo><ul id='QnZON'></ul>

        Laravel Eloquent::Find() 使用現有 ID 返回 NULL

        Laravel Eloquent::Find() returning NULL with an existing ID(Laravel Eloquent::Find() 使用現有 ID 返回 NULL)

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

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

          <tfoot id='dlLbY'></tfoot>
            <tbody id='dlLbY'></tbody>
          <i id='dlLbY'><tr id='dlLbY'><dt id='dlLbY'><q id='dlLbY'><span id='dlLbY'><b id='dlLbY'><form id='dlLbY'><ins id='dlLbY'></ins><ul id='dlLbY'></ul><sub id='dlLbY'></sub></form><legend id='dlLbY'></legend><bdo id='dlLbY'><pre id='dlLbY'><center id='dlLbY'></center></pre></bdo></b><th id='dlLbY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dlLbY'><tfoot id='dlLbY'></tfoot><dl id='dlLbY'><fieldset id='dlLbY'></fieldset></dl></div>
                <bdo id='dlLbY'></bdo><ul id='dlLbY'></ul>
                • 本文介紹了Laravel Eloquent::Find() 使用現有 ID 返回 NULL的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  它非常簡單,因為它是最基本的東西,但我不知道我錯過了什么:

                  It's pretty straightforward as it's the most basic thing but I don't know what I'm missing:

                  有一個名為 Site

                  我正在使用 Eloquent ORM,所以當我調用(在控制器中)

                  I'm using Eloquent ORM, so when I call (in a controller)

                  $oSite = Site::find(1)
                  

                  然后

                  var_dump($oSite);
                  

                  它返回一個 NULL 的值.

                  但是當我檢查數據庫時,表sites"實際上包含以下項目:

                  But when I check the database, the table 'sites' actually contains the following item:

                  id: 1
                  user_id: 1
                  name: test
                  

                  在我的 Site model 中,我有以下代碼:

                  In my Site model I have the following code:

                  use IlluminateDatabaseEloquentModelNotFoundException;
                  
                   Class Site extends Eloquent {
                  
                          protected $table = 'sites';
                  
                          protected $fillable = ['user_id', 'name'];
                   }
                  

                  相反,如果我使用以下內容收集項目:

                  Instead, if I gather the item with the following:

                  $oSite = DB::table('sites')
                                  ->where('id', 1)
                                  ->first();
                  

                  它有效并且我得到了正確的寄存器.

                  It works and I get the correct register.

                  我做錯了什么?我沒有得到文檔的哪一部分?

                  What I'm doing wrong? Which part of the documentation I didn't get?

                  型號代碼可以在上面查看.

                  Model code can be checked above.

                  控制器:

                  use IlluminateSupportFacadesRedirect;
                  class SiteManagementController extends BaseController {
                  
                  ...
                  
                      public function deleteSite()
                      {
                          if (Request::ajax())
                          {
                              $iSiteToDelete = Input::get('siteId');
                  
                              $oSite = Site::find($iSiteToDelete);
                  
                              return var_dump($oSite);
                          }
                          else
                          {
                              return false;
                          }
                      }
                  }
                  

                  編輯 2:(已解決)

                  不工作的真正原因:

                  我的模型代碼原本如下:

                  use IlluminateDatabaseEloquentSoftDeletingTrait;
                  use IlluminateDatabaseEloquentModelNotFoundException;
                  
                  Class Site extends Eloquent {
                  
                      protected $table = 'sites';
                  
                      use SoftDeletingTrait;
                  
                      protected $dates = ['deleted_at'];
                  
                      protected $fillable = ['user_id', 'name'];
                  }
                  

                  問題是我在啟動項目后添加了一個deleted_at"列,當我應用遷移時,我沒有啟用軟刪除.顯然,我犯了第二個錯誤,忘記啟用 'deleted_at' 為可空,因此所有插入的時間戳都錯誤(0000-00-00 ...).

                  Problem was I added a 'deleted_at' column after I started the project and when I applied migrations, I didn't have softdeleting enabled. Obviously, I did a second error, forgetting to enable 'deleted_at' to be nullable, hence all inserts went had a wrong timestamp (0000-00-00 ...).

                  修復:

                  1. 使deleted_at"列可以為空.

                  將所有錯誤的 'deleted_at' 時間戳設置為 NULL.

                  Set all wrong 'deleted_at' timestamps to NULL.

                  推薦答案

                  檢查您是否正確獲取了 Input::get('siteId').如果您得到它,請嘗試將其轉換為整數,即

                  Check you are getting Input::get('siteId') correctly. if you are getting it then try to convert it into integer i.e

                  $iSiteToDelete = intval(Input::get('siteId'));
                  

                  這篇關于Laravel Eloquent::Find() 使用現有 ID 返回 NULL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                    1. <i id='glxUw'><tr id='glxUw'><dt id='glxUw'><q id='glxUw'><span id='glxUw'><b id='glxUw'><form id='glxUw'><ins id='glxUw'></ins><ul id='glxUw'></ul><sub id='glxUw'></sub></form><legend id='glxUw'></legend><bdo id='glxUw'><pre id='glxUw'><center id='glxUw'></center></pre></bdo></b><th id='glxUw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='glxUw'><tfoot id='glxUw'></tfoot><dl id='glxUw'><fieldset id='glxUw'></fieldset></dl></div>
                    2. <tfoot id='glxUw'></tfoot>
                        <tbody id='glxUw'></tbody>
                        <bdo id='glxUw'></bdo><ul id='glxUw'></ul>

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

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

                          • 主站蜘蛛池模板: 波多野结衣精品在线 | 精品欧美乱码久久久久久1区2区 | 精品久久影院 | 国产电影一区二区 | 嫩草国产 | 国产欧美一区二区三区在线播放 | 日韩欧美一区二区三区免费看 | 日本亚洲一区 | 在线免费观看日本 | 999久久久 | 欧美专区日韩专区 | 欧美中文视频 | 黄色毛片网站在线观看 | 欧美一二三 | 精品入口麻豆88视频 | 午夜专区 | 99av成人精品国语自产拍 | 一区二区三区精品视频 | 男女羞羞视频在线 | 亚洲传媒在线 | 美日韩精品 | av色站| 国产精品a久久久久 | 91资源在线 | 毛片黄片免费看 | 久久久久久久一区二区三区 | 黄网站免费观看 | 欧美一区二区小视频 | 欧美在线 | 夜操| 欧美日韩精品一区 | 国产三级精品三级在线观看四季网 | 亚洲一区在线日韩在线深爱 | 国产成人综合在线 | 日韩一区二区不卡 | 午夜av一区二区 | 午夜精品久久久久久久星辰影院 | 亚洲视频中文字幕 | 日韩在线第一 | 在线午夜 | 一区二区影视 |