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

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

        <bdo id='e38zy'></bdo><ul id='e38zy'></ul>

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

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

        Laravel 在更新時更改 created_at

        Laravel changes created_at on update(Laravel 在更新時更改 created_at)

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

              • <bdo id='o79Kg'></bdo><ul id='o79Kg'></ul>
                <tfoot id='o79Kg'></tfoot>

                  <tbody id='o79Kg'></tbody>

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

                1. 本文介紹了Laravel 在更新時更改 created_at的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在這個主題上找到了這個答案,但它沒有不適合我.

                  I found this answer on the subject, but it doesn't work for me.

                  所以,我在數(shù)據(jù)庫中創(chuàng)建一個條目:

                  So, I make an entry in the database:

                  // Write lead to database
                  $lead = Lead::create($lead_data);
                  

                  時間戳看起來像這樣,這很好:

                  And the timestamps look like this, which is good:

                  | 2016-01-08 10:34:15 | 2016-01-08 10:34:15 |
                  

                  然后我向外部服務器發(fā)出請求,我需要更新該行:

                  But then I make a request to an external server, and I need to update the row:

                  $lead->user_id = $response['user_id'];
                  $lead->broker_id = $response['broker_id'];
                  $lead->save();
                  

                  并且 created_at 字段被更改:

                  and the created_at field gets changed:

                  | 2016-01-08 04:34:17 | 2016-01-08 10:34:17 |
                  

                  我該如何解決這個問題?

                  How do I solve this problem?

                  編輯

                  我需要一個解決方案,它只修改行為而不刪除列或重置遷移.必須在不接觸數(shù)據(jù)的情況下在實時數(shù)據(jù)庫上執(zhí)行修復.如下所示,我嘗試了以下遷移:

                  I need a solution that would just modify the behavior without dropping columns or resetting migrations. The fix has to be performed on a live database without touching the data. As suggested below, I tried the following migration:

                  $table->datetime('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->change();
                  

                  但沒有任何反應.created_at 字段仍會在更新時修改.

                  but nothing happens. The created_at field still gets modified on update.

                  推薦答案

                  如果您使用的是 Laravel 5.2 并使用 MySQL,那么時間戳會引入一些錯誤".您可以在 github 此處閱讀有關該問題的所有信息.它與時間戳默認值有關,MySQL 在某些條件下會自動分配 DEFAULT CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 屬性.

                  If you're on Laravel 5.2 and using MySQL, there was a bit of a "bug" introduced with the timestamps. You can read all about the issue on github here. It has to do with the timestamp defaults, and MySQL automatically assigning DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes under certain conditions.

                  基本上,您有三個選擇.

                  Basically, you have three options.

                  1. 更新 MySQL 變量:

                  如果您將 explicit_defaults_for_timestamp 變量設置為 TRUE,則不會自動為時間戳列分配 DEFAULT CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 屬性.您可以在這里閱讀更多關于變量的信息.

                  If you set the explicit_defaults_for_timestamp variable to TRUE, no timestamp column will be assigned the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes automatically. You can read more about the variable here.

                  1. 使用可為空的時間戳:

                  $table->timestamps() 更改為 $table->nullableTimestamps().默認情況下,$table->timestamps() 命令創(chuàng)建不可為空的時間戳字段.通過使用 $table->nullableTimestamps(),您的時間戳字段將可以為空,并且 MySQL 不會自動為第一個字段分配 DEFAULT CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 屬性.

                  Change $table->timestamps() to $table->nullableTimestamps(). By default, the $table->timestamps() command creates timestamp fields that are not nullable. By using $table->nullableTimestamps(), your timestamp fields will be nullable, and MySQL will not automatically assign the first one the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes.

                  1. 自己定義時間戳:

                  不要使用 $table->timestamps,而是使用 $table->timestamp('updated_at');$table->timestamp('created_at'); 你自己.確保您的updated_at"字段是表中的第一個時間戳,以便它自動分配 DEFAULT CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 屬性.

                  Instead of using $table->timestamps, use $table->timestamp('updated_at'); $table->timestamp('created_at'); yourself. Make sure your 'updated_at' field is the first timestamp in the table, so that it will be the one that is automatically assign the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes.

                  這篇關于Laravel 在更新時更改 created_at的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(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 找不到驅動程序)
                    <bdo id='Y587d'></bdo><ul id='Y587d'></ul>

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

                    • <legend id='Y587d'><style id='Y587d'><dir id='Y587d'><q id='Y587d'></q></dir></style></legend>

                          <tfoot id='Y587d'></tfoot>

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

                            <tbody id='Y587d'></tbody>

                            主站蜘蛛池模板: 久久91精品国产一区二区三区 | 欧美成ee人免费视频 | 一级黄大片 | 伊人久久大香线 | 国产激情在线观看视频 | 精品在线看| 亚洲国产一区二区在线 | 国产成人精品一区二区 | aa级毛片毛片免费观看久 | 天天拍天天操 | 免费在线视频a | 日韩at| 91新视频| xxx国产精品视频 | 在线免费观看黄视频 | 精品久久国产 | 国产精品视频一区二区三区不卡 | 国产黄视频在线播放 | 欧美日韩高清在线一区 | 久久天堂 | 欧美中文字幕一区二区三区亚洲 | 久久精品国产久精国产 | 日韩在线国产 | a级片在线| 国产网站在线播放 | av网站在线看 | 久久国产成人午夜av影院武则天 | 日本精品一区二区 | 亚洲精品久 | 亚洲一区二区三区在线播放 | 久久久婷 | 99精品一区二区 | 中文字幕不卡视频在线观看 | 超碰高清| 国产精品免费视频一区 | 亚洲精久久 | 欧美三区视频 | 嫩草研究影院 | 色综合色综合网色综合 | 蜜桃视频在线观看免费视频网站www | 日本精品一区二区 |