PDOStatement::debugDumpParams — Print a SQL preprocessing command (PHP 5 >= 5.1.0, PECL pdo >= 0.9.0)
bool PDOStatement::debugDumpParams ( void )
Directly print out the information contained in a prepared statement. Provide the SQL query being used, the number of parameters (Params) used, the list of parameters, parameter name, parameter type represented by an integer (paramtype), key name or position, value, and position in the query (if the current POD If the driver does not support it, it will be -1).
This is a function used for debugging, which directly outputs data under normal output conditions.Tip: As well as outputting results directly to the browser, you can use the output control function to capture the output of the current function and then (for example) save it to a string.
Only print the parameters in the statement at this moment. Additional parameters are not stored in the statement and are not printed.
There is no return value.
<?php/* Execute a prepared statement by binding PHP variables*/$calories = 150;$colour = 'red';$sth = $dbh->prepare('SELECT name, color, calories FROM fruit WHERE calories < :calories AND color = :colour');$sth->bindParam(':calories', $calories, PDO::PARAM_INT);$sth->bindValue(':colour', $colour, PDO::PARAM_STR, 12);$sth->execute();$sth->debugDumpParams();?>
The above routine will output:
SQL: [96] SELECT name, colour, calories FROM fruit WHERE calories < :calories AND color = :colourParams: 2Key: Name: [9] :caloriesparamno=-1name=[9] ":calories"is_param=1param_type=1Key: Name: [7] :colourparamno=-1name=[7] ":colour"is_param=1param_type=2
<?php/* Execute a prepared statement by binding PHP variables*/$calories = 150;$colour = 'red';$name = 'apple';$sth = $dbh->prepare('SELECT name, color , calories FROM fruit WHERE calories < ? AND color = ?');$sth->bindParam(1, $calories, PDO::PARAM_INT);$sth->bindValue(2, $colour, PDO::PARAM_STR);$sth->execute();$sth->debugDumpParams();?>
The above routine will output:
SQL: [82] SELECT name, colour, calories FROM fruit WHERE calories < ? AND color = ?Params: 2Key: Position #0:paramno=0name=[0] ""is_param=1param_type=1Key: Position #1:paramno= 1name=[0] ""is_param=1param_type=2