PDOStatement::debugDumpParams
PDOStatement::debugDumpParams - Print an SQL prepared command (PHP 5 >= 5.1.0, PECL pdo >= 0.9.0)
Description
Syntax
bool PDOStatement::debugDumpParams ( void )
Prints out the information contained in a prepared statement directly. Provides the SQL query in use, the number of parameters (Params) used, the list of parameters, parameter names, the parameter type represented by an integer (paramtype), key name or position, value, and position in the query (or -1 if the current PDO driver does not support it).
This is a debugging function that outputs data directly under normal output.
Tip: Like outputting results directly to the browser, output control functions can be used to capture the output of the current function and then (for example) save it to a string.
Only the parameters in the statement at that moment are printed. Extra parameters are not stored in the statement and thus are not output.
Return Value
No value is returned.
Example
An example of PDOStatement::debugDumpParams() using named parameters
prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour');
$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindValue(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();
$sth->debugDumpParams();
?>
The above example will output:
SQL: [96] SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour
Params: 2
Key: Name: [9] :calories
paramno=-1
name=[9] ":calories"
is_param=1
param_type=1
Key: Name: [7] :colour
paramno=-1
name=[7] ":colour"
is_param=1
param_type=2
An example of PDOStatement::debugDumpParams() using unnamed parameters
prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->bindParam(1, $calories, PDO::PARAM_INT);
$sth->bindValue(2, $colour, PDO::PARAM_STR);
$sth->execute();
$sth->debugDumpParams();
?>
The above example will output:
SQL: [82] SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?
Params: 2
Key: Position #0:
paramno=0
name=[0] ""
is_param=1
param_type=1
Key: Position #1:
paramno=1
name=[0] ""
is_param=1
param_type=2
PHP PDO Reference Manual