Bug #81037 [PATCH]: PDO discards error message text from prepared statement
| From: | cmb@php.net | Date: | Thu, 13 May 2021 18:33:52 +0000 |
| Subject: | Bug #81037 [PATCH]: PDO discards error message text from prepared statement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233823@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
Patch added by: cmb@php.net
Reported by: dharman@php.net
Summary: PDO discards error message text from prepared
statement
Status: Open
Type: Bug
Package: PDO MySQL
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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