php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52384 PDOStatement::debugDumpParams does not emit the bind parameter value
Submitted: 2010-07-20 23:43 UTC Modified: 2016-07-25 15:28 UTC
Votes:138
Avg. Score:4.3 ± 0.9
Reproduced:132 of 134 (98.5%)
Same Version:49 (37.1%)
Same OS:45 (34.1%)
From: jonah dot harris at gmail dot com Assigned: bishop (profile)
Status: Closed Package: PDO related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-07-20 23:43 UTC] jonah dot harris at gmail dot com
Description:
------------
Per the PDO documentation, PDOStatement::debugDumpParams should emit the bind parameter value.  Currently however, it does not.  Attached is a patch for 5.2 (which also applies cleanly to 5.3), which emits the bind parameter value.

Test script:
---------------
<?php
$dbh = new PDO("sqlite:test.sdb");
$calories = (int) 150; /* Force a type conversion to string */
$colour = 'red';
$sth = $dbh->prepare('SELECT 1 WHERE 1 = :calories AND 2 = :colour');
if ($sth->bindParam(':calories', $calories, PDO::PARAM_INT) !== true)
    die('die on ' . __LINE__. "\n");
if ($sth->bindValue(':colour', $colour, PDO::PARAM_STR) !== true)
    die('die on ' . __LINE__. "\n");

$sth->debugDumpParams();


Expected result:
----------------
With Patch:

SQL   : [len = 44] SELECT 1 WHERE 1 = :calories AND 2 = :colour
Params: 2
Key: Name: [9] :calories
paramno=-1
name=[9] ":calories"
is_param=1
param_type=1
value=150
Key: Name: [7] :colour
paramno=-1
name=[7] ":colour"
is_param=1
param_type=2
value=red


Actual result:
--------------
SQL: [44] SELECT 1 WHERE 1 = :calories AND 2 = :colour
Params:  2
Key: Name: [9] :calories
paramno=-1
name=[9] ":calories"
is_param=1
param_type=1
Key: Name: [7] :colour
paramno=-1
name=[7] ":colour"
is_param=1
param_type=2


Patches

pdo_debugDumpParams_p3.txt (last revision 2010-07-20 21:44 UTC by jonah dot harris at gmail dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-29 01:22 UTC] cdotgutierrez at gmail dot com
I am seeing the same issue on PHP 5.3.3 on OSX. I've tried it using the same
test script that is provided in the original ticket.
 [2011-09-15 11:54 UTC] php at nedge2k dot com
problem also exists in php 5.3 for windoze
 [2013-05-29 07:41 UTC] cedric dot bethencourt at gmail dot com
same problem with PHP 5.3.3 on Linux Debian
 [2014-02-02 10:12 UTC] bugs dot php dot net at dotancohen dot com
I can confirm this issue on Ubuntu Server 12.04 with PHP 5.3.10. The output of debugDumpParams() does not display the value of bound parameters.
 [2015-06-06 02:00 UTC] felipsmartins at gmail dot com
I run into the same issue. At 2015-06-05
 [2015-10-31 22:17 UTC] knl at bitflop dot com
The problem still exist in PHP 5.6.14 on Debian Jessie.

Could we please get this fixes ASAP!
 [2015-12-07 18:07 UTC] cjromb at gmail dot com
It's still an issue in 5.6.16

Input:  

    $stmt = $dbh->prepare("SELECT * FROM clients WHERE name LIKE :name");

    $name = "%Boy%";

    $stmt->bindParam(':name',$name, PDO::PARAM_STR);

    if($stmt->execute()):
        echo "It executed.  Here's what it executed";
        $stmt->debugDumpParams();
     endif;  // shortened for this comment

OUTPUT


It executed.  Here's what it executedSQL: [43] SELECT * FROM clients WHERE name LIKE :name
Params:  1
Key: Name: [5] :name
paramno=-1
name=[5] ":name"
is_param=1
param_type=2

^^ Note no param value!
 [2016-05-23 16:32 UTC] aaron at acwpd dot com
Confirming this is still present on PHP 7.0.6-8+donate.sury.org~trusty+1 on Ubuntu  ubuntu1404-x64 (via vagrant box puphpet/ubuntu1404-x64)
 [2016-07-09 11:42 UTC] cmb@php.net
Current behavior confirmed: <https://3v4l.org/lfMaV>.

> Could we please get this fixes ASAP!

In a strict sense this is not a bug, so it can't be fixed. The
suggested improvement seems to be reasonable, though. A Github PR
for PHP-7.1 including a PHPT (and/or fixing existing PHPTs) would
certainly be welcome.
 [2016-07-11 18:09 UTC] bishop@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bishop
 [2016-07-12 09:43 UTC] jpauli@php.net
-Status: Assigned +Status: Feedback
 [2016-07-12 09:43 UTC] jpauli@php.net
Please try using this snapshot:

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2016-07-12 14:12 UTC] jpauli@php.net
-Status: Feedback +Status: Re-Opened
 [2016-07-12 14:12 UTC] jpauli@php.net
The test keeps failing under pgsql , please check it, as well as other RDBMS.
 [2016-07-25 15:28 UTC] bishop@php.net
-Status: Re-Opened +Status: Closed
 [2016-07-25 15:28 UTC] bishop@php.net
@jpauli PR 1999 updated to fix PostgreSQL and other major RDMS drivers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 23:01:31 2024 UTC