Created
August 5, 2020 14:05
-
-
Save zgia/08581e652c8e43e7aed13337f60551d3 to your computer and use it in GitHub Desktop.
PDOStatement::debugDumpParams
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
$dbh = new PDO('mysql:host=127.0.0.1;dbname=mysql', 'root', 'pwd'); | |
$host = 'localhost'; | |
$sth = $dbh->prepare('SELECT * FROM user WHERE Host = :host'); | |
$sth->bindValue(':host', $host, PDO::PARAM_STR); | |
$sth->execute(); | |
ob_start(); | |
$sth->debugDumpParams(); | |
$dump = ob_get_contents(); | |
ob_end_clean(); | |
$sth = null; | |
$dbh = null; | |
$tmp = explode("\n", $dump); | |
var_dump(substr($tmp[1], stripos($tmp[1], 'SELECT'))); | |
} catch (PDOException $e) { | |
print "Error!: " . $e->getMessage() . PHP_EOL; | |
} | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment