php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81037 PDO discards error message text from prepared statement
Submitted: 2021-05-13 12:45 UTC Modified: -
From: dharman@php.net Assigned:
Status: Closed Package: PDO MySQL
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2021-05-13 12:45 UTC] 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"

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-13 18:33 UTC] 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-14 11:05 UTC] 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-14 11:05 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC