pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="llxrtpf" 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 在關(guān)系中四舍五入為 int

        Laravel bigInteger being rounded to int in relationship(Laravel bigInteger 在關(guān)系中四舍五入為 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="x99rr1r" 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 在關(guān)系中四舍五入為 int的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

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

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

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

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

                  我的問題是 Instagram 與用戶的關(guān)系不起作用.我無法從 Instagram 訪問用戶,即使他們都在數(shù)據(jù)庫中.

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

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

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

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

                  解決方案

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

                  問題是當(dāng)關(guān)系查詢獲取Instagram 實(shí)例的鍵值來查詢用戶時(shí),它會(huì)自動(dòng)將該id 值轉(zhuǎn)換為$keyType 模型上的屬性.此屬性默認(rèn)為 int.

                  因此,即使您的 Instagram 實(shí)例 ID 是 "3620243170",它也會(huì)被轉(zhuǎn)換為 int,在 32 位 PHP 中會(huì)將其轉(zhuǎn)換為 2147483647.

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

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

                  2. Instagram 模型上的 $keyType 屬性更改為 float,或者可能是 string.這只會(huì)影響 Eloquent 在 PHP 中對變量的轉(zhuǎn)換,不會(huì)影響它們在數(shù)據(jù)庫中的存儲方式.
                    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.

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

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

                  相關(guān)文檔推薦

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

                          1. 主站蜘蛛池模板: 智能案卷柜_卷宗柜_钥匙柜_文件流转柜_装备柜_浙江福源智能科技有限公司 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | 桂林腻子粉_内墙外墙抗裂砂浆腻子粉推荐广西鑫达涂料厂家供应 | 防腐储罐_塑料储罐_PE储罐厂家_淄博富邦滚塑防腐设备科技有限公司 | 餐饮小吃技术培训-火锅串串香培训「何小胖培训」_成都点石成金[官网] | 西门子代理商_西门子变频器总代理-翰粤百科 | 精密光学实验平台-红外粉末压片机模具-天津博君 | 餐饮加盟网_特色餐饮加盟店_餐饮连锁店加盟| 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | 在线钠离子分析仪-硅酸根离子浓度测定仪-油液水分测定仪价格-北京时代新维测控设备有限公司 | 济南品牌设计-济南品牌策划-即合品牌策划设计-山东即合官网 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 压滤机滤板_厢式_隔膜_板框压滤机滤板厂家价格型号材质-大凯环保 | 行吊_电动单梁起重机_双梁起重机_合肥起重机_厂家_合肥市神雕起重机械有限公司 | 北京环球北美考试院【官方网站】|北京托福培训班|北京托福培训 | 【官网】博莱特空压机,永磁变频空压机,螺杆空压机-欧能优 | 全温恒温摇床-水浴气浴恒温摇床-光照恒温培养摇床-常州金坛精达仪器制造有限公司 | 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | 电脑知识|软件|系统|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网 | 工业车间焊接-整体|集中除尘设备-激光|等离子切割机配套除尘-粉尘烟尘净化治理厂家-山东美蓝环保科技有限公司 | 高低温试验箱-模拟高低温试验箱订制-北京普桑达仪器科技有限公司【官网】 | 3A别墅漆/3A环保漆_广东美涂士建材股份有限公司【官网】 | SMC-SMC电磁阀-日本SMC气缸-SMC气动元件展示网 | 板式换网器_柱式换网器_自动换网器-郑州海科熔体泵有限公司 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 生鲜配送系统-蔬菜食材配送管理系统-连锁餐饮订货配送软件-挪挪生鲜供应链管理软件 | 天津仓储物流-天津电商云仓-天津云仓一件代发-博程云仓官网 | 点焊机-缝焊机-闪光对焊机-电阻焊设备生产厂家-上海骏腾发智能设备有限公司 | 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | 胶泥瓷砖胶,轻质粉刷石膏,嵌缝石膏厂家,腻子粉批发,永康家德兴,永康市家德兴建材厂 | 北京租车牌|京牌指标租赁|小客车指标出租 | 卫生人才网-中国专业的医疗卫生医学人才网招聘网站! | 铝合金线槽_铝型材加工_空调挡水板厂家-江阴炜福金属制品有限公司 | 金属软管_不锈钢金属软管_巩义市润达管道设备制造有限公司 | 幂简集成 - 品种超全的API接口平台, 一站搜索、试用、集成国内外API接口 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 体检车_移动CT车_CT检查车_CT车_深圳市艾克瑞电气有限公司移动CT体检车厂家-深圳市艾克瑞电气有限公司 | 广西教师资格网-广西教师资格证考试网 | 厌氧工作站-通用型厌氧工作站-上海胜秋科学仪器有限公司 | 【中联邦】增稠剂_增稠粉_水性增稠剂_涂料增稠剂_工业增稠剂生产厂家 |