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

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

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

        Laravel bigInteger 在關系中四舍五入為 int

        Laravel bigInteger being rounded to int in relationship(Laravel bigInteger 在關系中四舍五入為 int)
          <tbody id='h3nUB'></tbody>
      1. <i id='h3nUB'><tr id='h3nUB'><dt id='h3nUB'><q id='h3nUB'><span id='h3nUB'><b id='h3nUB'><form id='h3nUB'><ins id='h3nUB'></ins><ul id='h3nUB'></ul><sub id='h3nUB'></sub></form><legend id='h3nUB'></legend><bdo id='h3nUB'><pre id='h3nUB'><center id='h3nUB'></center></pre></bdo></b><th id='h3nUB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='h3nUB'><tfoot id='h3nUB'></tfoot><dl id='h3nUB'><fieldset id='h3nUB'></fieldset></dl></div>

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

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

              1. <tfoot id='h3nUB'></tfoot>
                  <bdo id='h3nUB'></bdo><ul id='h3nUB'></ul>
                • 本文介紹了Laravel bigInteger 在關系中四舍五入為 int的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  好的,這是我的遷移...

                  公共函數 up(){Schema::create('instagrams', function (Blueprint $table) {$table->bigInteger('id')->unsigned()->primary();//...});}公共函數 up(){Schema::create('users', function (Blueprint $table) {$table->increments('id');$table->bigInteger('instagram_id')->unsigned()->nullable();//...});}

                  我有一個用戶模型和一個 instagram 模型.這是我的 Instagram 模型:

                  class Instagram 擴展模型{公共函數用戶(){返回 $this->hasOne('AppUser');}}

                  我的問題是 Instagram 與用戶的關系不起作用.我無法從 Instagram 訪問用戶,即使他們都在數據庫中.

                  <預><代碼>>>>$u = AppUser::first()=>應用用戶 {#695編號:1,instagram_id: "3620243170",}>>>$i = AppInstagram::first()=>應用Instagram {#696id: "3620243170",}>>>$i->用戶=>空值

                  所以,我花了很長時間絞盡腦汁,直到找到這些有用的修補方法……這就是它給我的:

                  <預><代碼>>>>$i->user()->toSql()=>從`users` 中選擇* 其中`users`.`instagram_id` = ? 并且`users`.`instagram_id` 不為空">>>$i->user()->getBindings()=>[2147483647,]

                  除了 ID 被隱藏在 Laravel 中的任何代碼限制在 32 位限制之外,一切都井然有序……ID 需要大于 32 位,因為 Instagram 的 ID 就是這樣存儲的.我怎樣才能讓這種關系發揮作用?

                  解決方案

                  聽起來您使用的是 32 位版本的 PHP,其中最大整數值為 2147483647.

                  問題是當關系查詢獲取Instagram 實例的鍵值來查詢用戶時,它會自動將該id 值轉換為$keyType 模型上的屬性.此屬性默認為 int.

                  因此,即使您的 Instagram 實例 ID 是 "3620243170",它也會被轉換為 int,在 32 位 PHP 中會將其轉換為 2147483647.

                  您可以嘗試幾種方法來緩解此問題:

                  1. 使用 64 位版本的 PHP.64 位 PHP 的最大 int 大小與可用于有符號 bigint 字段的最大 int 匹配.但是,如果您使用的是未簽名的 bigint,一旦您的 ID 超過 9223372036854775807(不太可能),您就會再次遇到此問題.

                  2. Instagram 模型上的 $keyType 屬性更改為 float,或者可能是 string.這只會影響 Eloquent 在 PHP 中對變量的轉換,不會影響它們在數據庫中的存儲方式.
                    protected $keyType = 'float'; 添加到您的 Instagram 模型中.

                  Alright, so here's my migrations...

                  public function up()
                  {
                      Schema::create('instagrams', function (Blueprint $table) {
                          $table->bigInteger('id')->unsigned()->primary();
                          // ...
                      });
                  }
                  
                  
                  public function up()
                  {
                      Schema::create('users', function (Blueprint $table) {
                          $table->increments('id');
                          $table->bigInteger('instagram_id')->unsigned()->nullable();
                          // ...
                      });
                  }
                  

                  I have a user model, and an instagram model. Here's my instagram model:

                  class Instagram extends Model
                  {
                      public function user()
                      {
                          return $this->hasOne('AppUser');
                      }
                  }
                  

                  My problem is the instagram's relationship with the user isn't working. I can't access the user from an instagram, even when they're both in the database.

                  >>> $u = AppUser::first()
                  => AppUser {#695
                       id: 1,
                       instagram_id: "3620243170",
                     }
                  >>> $i = AppInstagram::first()
                  => AppInstagram {#696
                       id: "3620243170",
                     }
                  >>> $i->user
                  => null
                  

                  So, I spent a long time wracking my brain until I found these helpful tinker methods... here's what it's giving me:

                  >>> $i->user()->toSql()
                  => "select * from `users` where `users`.`instagram_id` = ? and `users`.`instagram_id` is not null"
                  >>> $i->user()->getBindings()
                  => [
                       2147483647,
                     ]
                  

                  Everything is in order except the ID is being maxed at the 32 bit limit by whatever code is hiding in laravel... the ID needs to be bigger than 32 bits because that's how instagram's IDs are stored. How can I get this relationship to work?

                  解決方案

                  It sounds like you're using a 32-bit version of PHP, where the max integer value is 2147483647.

                  The issue is that when the relationship query gets the key value of the Instagram instance to query the users, it automatically casts that id value to the type defined by the $keyType property on the model. This property is int by default.

                  So, even though your Instagram instance id is "3620243170", it is cast to an int, which in 32-bit PHP will turn it into 2147483647.

                  There are a couple things you can try to mitigate this issue:

                  1. Use a 64-bit version of PHP. The max int size for 64-bit PHP matches the max int available for a signed bigint field. However, if you're using an unsigned bigint, you will run into this issue again once your ids exceed 9223372036854775807 (not likely).

                  2. Change the $keyType property on your Instagram model to float, or possibly string. This only affects Eloquent's casting of the variables in PHP, it does not affect how they are stored in the database.
                    Add protected $keyType = 'float'; to your Instagram model.

                  這篇關于Laravel bigInteger 在關系中四舍五入為 int的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  <tfoot id='7sNSd'></tfoot>

                    <tbody id='7sNSd'></tbody>

                    <legend id='7sNSd'><style id='7sNSd'><dir id='7sNSd'><q id='7sNSd'></q></dir></style></legend>
                  1. <small id='7sNSd'></small><noframes id='7sNSd'>

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

                          1. 主站蜘蛛池模板: 国产精品久久久久久久久久三级 | 91美女在线观看 | 亚洲人成在线观看 | a级片网站 | 欧美一级免费看 | 欧美视频二区 | 逼逼视频 | 91视频在线看 | 国产精品久久久久久久久久久久冷 | 成人免费观看视频 | 亚洲一二三在线观看 | 精品1区| 国产片侵犯亲女视频播放 | 亚洲女人天堂成人av在线 | 一区二区在线 | 欧美久久一区二区三区 | 国外成人在线视频 | 中文字幕一区二区三区四区五区 | 日韩无| 99精品一级欧美片免费播放 | 日韩电影一区二区三区 | 99精品视频在线 | 成人黄色在线观看 | 久久亚洲一区二区三区四区 | 日韩欧美国产精品一区二区 | 久久久久国产精品免费免费搜索 | 欧美a级成人淫片免费看 | 精品91| 日韩高清中文字幕 | 中文字幕在线精品 | 欧美一级二级三级视频 | 亚洲一区视频 | 午夜影院黄 | 91久久久久久久久 | 本道综合精品 | 在线免费观看成年人视频 | 精品国产一区二区久久 | 超碰在线免费av | 欧美日一区 | 亚洲精品国产电影 | 久久久久久久国产精品 |