|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
Patchespdo_debugDumpParams_p3.txt (last revision 2010-07-20 21:44 UTC by jonah dot harris at gmail dot com)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
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!