Bug #76400 [Opn->Nab]: PDO cannot caught mysql error 1690:bigint unsigned value is out of range
Edit report at https://bugs.php.net/bug.php?id=76400&edit=1
ID: 76400
Updated by: cmb@php.net
Reported by: kadovat at gmail dot com
Summary: PDO cannot caught mysql error 1690:bigint unsigned
value is out of range
-Status: Open
+Status: Not a bug
Type: Bug
Package: PDO MySQL
Operating System: Linux
PHP Version: 5.6.36
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
If you want PDO to throw exceptions, you have to tell it to:
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Previous Comments:
------------------------------------------------------------------------
[2018-06-01 06:56:43] kadovat at gmail dot com
MySQL cli show error like this:
mysql> select id,pv-yesterday_pv from test;
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in
'(DB_ad_fengye.test.pv -
DB_ad_fengye.test.yesterday_pv)'
------------------------------------------------------------------------
[2018-06-01 06:50:57] kadovat at gmail dot com
Description:
------------
PDO doesn't throw an exception when occurs mysql error 1690:bigint unsigned value is out of
rangeï¼just return an empty array
Test script:
---------------
# CREATE TABLE test (id int(10) unsigned DEFAULT NULL, pv
int(10) unsigned DEFAULT NULL,yesterday_pv int(10) unsigned DEFAULT NULL) ENGINE=InnoDB
DEFAULT CHARSET=utf8
#insert into test set id=1,pv=1,yesterday_pv=2;
<?php
$dbh = new PDO("mysql:host=localhost;port=3306;dbname=testdb","root");
$sth = $dbh->prepare('select id,pv-yesterday_pv from test');
$sth->execute();
$result = $sth->fetchAll();
var_dump($result);
Expected result:
----------------
throw a PDOException
Actual result:
--------------
array(0) {
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76400&edit=1
Thread (3 messages)