I am trying to create a useful email to myself on pdo mysql errors, I am looking at "debugDumpParams", but sadly for some reason it just dumps the info right on the screen, you need to use output control functions to set it to a string which i don't quite understand.
Is there anything like that, that is settable to a string easily?
The debugDumpParams()
method writes to standard output. You can use an output buffer to capture standard output into a string. The following code works for me, based on one of the comments to imagepng()
in the online manual :
function pdo_debugStrParams($stmt) {
ob_start();
$stmt->debugDumpParams();
$r = ob_get_contents();
ob_end_clean();
return $r;
}
// omitted: connect to the database and prepare a statement
echo '<pre>'.htmlspecialchars(pdo_debugStrParams($stmt)).'</pre>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With