【发布时间】:2019-11-15 06:42:09
【问题描述】:
我有一张表,其中一列是 request_id,它在迁移中定义如下:
$table->bigInteger('request_id')->index()->unsigned()->nullable();
当我在表结构中查看 phpmyadmin 时,它说
bigint(20) UNSIGNED
我正在向我的 api 发出请求,并通过此值发送:1562247865319
$requestLog = new RequestLog();
$requestLog->request_id = 1562247865319;
$requestLog->save();
此代码出错并返回超出范围的数值:1264 超出范围
真正奇怪的是,当我在 phpmyadmin 中时,我可以手动将该列的值设置为比 1562247865319 大得多的值,但是当我通过我的 laravel 模型进行设置时,它不喜欢它。
编辑
错误信息是
SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'request_id' at row 1 (SQL: insert into `request_logs` (`ip`, `submitted_user_name`, `url`, `full_url`, `method`, `request_id`, `request_data`, `api_user_id`, `updated_at`, `created_at`) values (..., ..., ..., http://..../api/..., POST, 1562247865319, {"request_id":"1562248616206"}, 2, 2019-07-04 14:57:00, 2019-07-04 14:57:00))
【问题讨论】:
-
请我们总是看到完整和完整的错误消息!不是它的摘要
-
您的
PHP_INT_MAX值是多少? -
@Haru int size 8, int max 9223372036854775807