Something like debugDumpParams in pdo set to string

I'm trying to create a useful email for myself on pdo mysql errors, I look at "debugDumpParams", but unfortunately for some reason it just dumps the information right on the screen, you need to use the output control functions to install this is the line I I do not get you.

Is there anything like this that can be easily tuned to a string?

+4
source share
1 answer

The following code works for me based on one of the comments 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>';
+6
source

Source: https://habr.com/ru/post/1529886/


All Articles