Bug #81037 [Com]: PDO discards error message text from prepared statement
| From: | bouazizrahma5 at gmail dot com | Date: | Sat, 06 May 2023 13:52:39 +0000 |
| Subject: | Bug #81037 [Com]: PDO discards error message text from prepared statement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-244390@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81037&edit=1
ID: 81037
Comment by: bouazizrahma5 at gmail dot com
Reported by: dharman@php.net
Summary: PDO discards error message text from prepared
statement
Status: Closed
Type: Bug
Package: PDO MySQL
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
8888
Previous Comments:
------------------------------------------------------------------------
[2021-05-14 11:05:35] git@php.net
Automatic comment on behalf of kamil-tekiela
Revision: https://github.com/php/php-src/commit/6afbb7419458f0b2f40284a295be07f03b3b5a65
Log: Fixed bug #81037 PDO discards error message text from prepared statement
------------------------------------------------------------------------
[2021-05-13 18:33:52] cmb@php.net
The following pull request has been associated:
Patch Name: Fix Bug #81037 PDO discards error message text from prepared statement
On GitHub: https://github.com/php/php-src/pull/6978
Patch: https://github.com/php/php-src/pull/6978.patch
------------------------------------------------------------------------
[2021-05-13 12:45:13] dharman@php.net
Description:
------------
When executing a prepared statement in non-emulated mode PDO reports an error, but only with the
code without the actual error message text.
Test script:
---------------
<?php
$pdo = new \PDO("mysql:host=localhost;dbname=test;charset=utf8mb4", 'user',
'password', [
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_EMULATE_PREPARES => false
]);
$sql = "SELECT
foo FROM bar WHERE foo = :par";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
Expected result:
----------------
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2031 No data supplied for
parameters in prepared statement in
Actual result:
--------------
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2031 in
// Notice the text is missing between error code and the "in"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81037&edit=1