PDO PHP - PDOException - 数值超出范围:1264 第 1 行的列“customer_id”的值超出范围

Posted

技术标签:

【中文标题】PDO PHP - PDOException - 数值超出范围:1264 第 1 行的列“customer_id”的值超出范围【英文标题】:PDO PHP - PDOException - Numeric value out of range: 1264 Out of range value for column 'customer_id' at row 1 【发布时间】:2016-09-24 06:54:35 【问题描述】:

我正在尝试使用单个“多次插入”查询(php 的 PDO 驱动程序)将大量行 (400-2500) 推送到表中。

现在我收到此错误:

致命错误:带有消息的未捕获异常“PDOException” 'SQLSTATE [22003]:数值超出范围:1264 超出范围值 对于第 1 行的列“customer_id”

但据我所知,它没有尝试在任何地方插入值1264,尤其是在customer_id 列中。 此外,我准备好的查询中 ?s 的数量与我传递给 execute() 调用的数组中的项目数量相匹配。

if ((!in_array(true, $this->issuesCallsErrors)) && (substr_count($this->sql, '?') === count($this->issues))) 
    var_dump(substr_count($this->sql, '?')); //int: 3600
    var_dump(count($this->issues));          //int: 3600
    echo $this->sql;
    print_r($this->issues);

    $query = DBCon::getCon()->query('TRUNCATE TABLE `issue`');
    $query = DBCon::getCon()->prepare($this->sql);
    $query->execute($this->issues);

    ...


编辑:一些外部信息

尝试插入customer_id 的最大值是193customer_idsmallint(5), unsigned 如果我没记错的话,它允许最大值为 65535

【问题讨论】:

可以查看that on *** 【参考方案1】:

1264 不是一个值。这是错误代码。 也许您尝试插入的 customer_id 值超过 2147483647。

【讨论】:

【参考方案2】:

您可以尝试手动更改表格并将“customer_id”从“int”更改为“bigint”

【讨论】:

以上是关于PDO PHP - PDOException - 数值超出范围:1264 第 1 行的列“customer_id”的值超出范围的主要内容,如果未能解决你的问题,请参考以下文章

PDO 扩展配置 - 我在我的 PHP 应用程序中不断收到 PDOException“找不到驱动程序”

PDO PHP - PDOException - 数值超出范围:1264 第 1 行的列“customer_id”的值超出范围

PDOException::("PDO::__construct(): 使用 MySQL 8 / PHP 7.2 / Laravel 进行缓存_sha2 auth: 109 时出现意外的服务

[PDOException] PDO::__construct(): php_network_getaddresses: getaddrinfo failed:

我尝试获取时PDOException(PDO :: FETCH_ASSOC)[重复]

PHP的死锁异常代码,MySQL PDOException?