dou31797719 2016-10-04 07:24
浏览 58
已采纳

BIGINT改为指数级

I have a sqlite table - addresses as below:

+-----------------------------+
|   appid   |   BIGINT (20)   |
|  address  |   CHAR(300)     |
|   addr_id |   BIGINT(11)    |
+-----------------------------+

However, when I try to save data in appid with very large number, I get something like 9.0916073007e+18. I tried using real but that did not work either.

How should I fix this issue?

EDIT:

$qry = "select * from addresses WHERE id  = 18";
$result = $db->query($qry);
while($row = $result->fetchArray(SQLITE3_ASSOC) ){
     var_dump($row['appid']);  // float(9.0916073007e+18)
}
  • 写回答

1条回答 默认 最新

  • dsm1998 2016-10-04 08:07
    关注

    SQLite supports signed 64-bit integers, i.e., values up to 9223372036854775807:

    sqlite> create table t(x);
    sqlite> insert into t values(9223372036854775807);
    sqlite> select * from t;
    9223372036854775807
    

    However, the PHP documentation says:

    The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit.
    […]
    If PHP encounters a number beyond the bounds of the integer type, it will be interpreted as a float instead.

    So you have to upgrade to a recent enough 64-bit version of PHP. Or handle the values as strings.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程