YouTip LogoYouTip

Pdostatement Debugdumpparams

# PDOStatement::debugDumpParams [![Image 3: PHP PDO Reference](#)PHP PDO Reference](#) PDOStatement::debugDumpParams β€” Prints a SQL prepared statement (PHP 5 >= 5.1.0, PECL pdo >= 0.9.0) * * * ## Description ### Syntax bool PDOStatement::debugDumpParams ( void ) Directly prints the information contained in a prepared statement. Provides the SQL query being used, the number of parameters (Params) used, a list of parameters, parameter names, parameter types represented by an integer (paramtype), key names or positions, values, and their position in the query (or -1 if the current PDO driver does not support this). This is a debugging function that outputs data directly to the normal output. **Tip:** Just like outputting results directly to the browser, you can use output control functions to capture the output of this function and then (for example) save it to a string. Only prints the parameters in the statement at this moment. Extra parameters are not stored in the statement and will not be output. * * * ## Return Value No return value. * * * ## Examples ### Example using named parameters with PDOStatement::debugDumpParams() prepare('SELECT name, colour, calories FROM fruit WHERE calories bindParam(':calories', $calories, PDO::PARAM_INT); $sth->bindValue(':colour', $colour, PDO::PARAM_STR, 12); $sth->execute(); $sth->debugDumpParams();?> The above example will output: SQL: SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour Params: 2Key: Name: :calories paramno=-1 name= ":calories" is_param=1 param_type=1Key: Name: :colour paramno=-1 name= ":colour" is_param=1 param_type=2 ### Example using unnamed parameters with PDOStatement::debugDumpParams() prepare('SELECT name, colour, calories FROM fruit WHERE calories bindParam(1, $calories, PDO::PARAM_INT); $sth->bindValue(2, $colour, PDO::PARAM_STR); $sth->execute(); $sth->debugDumpParams();?> The above example will output: SQL: SELECT name, colour, calories FROM fruit WHERE calories < ? AND colour = ?Params: 2Key: Position #0: paramno=0 name= "" is_param=1 param_type=1Key: Position #1: paramno=1 name= "" is_param=1 param_type=2 * * PHP PDO Reference](#)
← Pdostatement ErrorcodePdostatement Columncount β†’