note 113400 added to pdostatement.debugdumpparams
| From: | mark at manngo dot net | Date: | Mon, 07 Oct 2013 01:21:32 +0000 |
| Subject: | note 113400 added to pdostatement.debugdumpparams | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196480@lists.php.net to get a copy of this message | ||
As noted, this doesnât actually simply print the prepared statement with data to be executed.
For trouble shooting purposes, I find the following useful:
<?php
function parms($string,$data) {
$indexed=$data==array_values($data);
foreach($data as $k=>$v) {
if(is_string($v)) $v="'$v'";
if($indexed) $string=preg_replace('/\?/',$v,$string,1);
else $string=str_replace(":$k",$v,$string);
}
return $string;
}
// Index Parameters
$string='INSERT INTO stuff(name,value) VALUES (?,?)';
$data=array('Fred',23);
// Named Parameters
$string='INSERT INTO stuff(name,value) VALUES (:name,:value)';
$data=array('name'=>'Fred','value'=>23);
print parms($string,$data);
?>
----
Server IP: 113.20.13.217
Probable Submitter: 27.32.215.64
----
Manual Page -- http://php.net/manual/en/pdostatement.debugdumpparams.php
Edit -- https://master.php.net/note/edit/113400
Del: integrated -- https://master.php.net/note/delete/113400/integrated
Del: useless -- https://master.php.net/note/delete/113400/useless
Del: bad code -- https://master.php.net/note/delete/113400/bad+code
Del: spam -- https://master.php.net/note/delete/113400/spam
Del: non-english -- https://master.php.net/note/delete/113400/non-english
Del: in docs -- https://master.php.net/note/delete/113400/in+docs
Del: other reasons-- https://master.php.net/note/delete/113400
Reject -- https://master.php.net/note/reject/113400
Search -- https://master.php.net/manage/user-notes.php