Bug #79808 [Opn->Nab]: fetch General error
| From: | twosee@php.net | Date: | Sat, 11 Jul 2020 19:34:56 +0000 |
| Subject: | Bug #79808 [Opn->Nab]: fetch General error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227966@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79808&edit=1
ID: 79808
Updated by: twosee@php.net
Reported by: admin at yurunsoft dot com
Summary: fetch General error
-Status: Open
+Status: Not a bug
Type: Bug
Package: PDO MySQL
Operating System: Linux
PHP Version: 8.0.0alpha1
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is due to the default error mode of PDO is
PDO::ERRMODE_EXCEPTION now, see: https://wiki.php.net/rfc/pdo_default_errmode
In previous versions of PHP, you can check it by:
code:
```php
var_dump($stmt->errorCode());
var_dump($stmt->errorInfo());
```
output:
```
string(5) "HY000"
array(3) {
[0]=>
string(5) "HY000"
[1]=>
NULL
[2]=>
NULL
}
```
It may seem unreasonable to you, but it is as expected
Previous Comments:
------------------------------------------------------------------------
[2020-07-08 08:53:36] admin at yurunsoft dot com
Description:
------------
The bug is only in php8
Test script:
---------------
<?php
$pdo = new PDO('mysql:host=192.168.0.222;port=3306;dbname=db_imi_test;charset=utf8',
'root', 'root');
$stmt = $pdo->query('update tb_article set id = 1 where id = 1');
var_dump($stmt);
var_dump($stmt->fetch());
Expected result:
----------------
object(PDOStatement)#2 (1) {
["queryString"]=>
string(41) "update tb_article set id = 1 where id = 1"
}
bool(false)
Actual result:
--------------
object(PDOStatement)#2 (1) {
["queryString"]=>
string(40) "update tb_member set id = 1 where id = 1"
}
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error in
/mnt/d/projects/imi/test2.php:5
Stack trace:
#0 /mnt/d/projects/imi/test2.php(5): PDOStatement->fetch()
#1 {main}
thrown in /mnt/d/projects/imi/test2.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79808&edit=1