Latest web development tutorials

PDOStatement :: debugDumpParams

PHP PDO Reference Manual PHP PDO Reference Manual

PDOStatement :: debugDumpParams - print a SQL command preprocessing (PHP 5> = 5.1.0, PECL pdo> = 0.9.0)


Explanation

grammar

bool PDOStatement::debugDumpParams ( void )

Direct print out information contained in a prepared statement. Provides SQL queries are being used, the use of the list, the parameter name parameter (Params) the number of parameters, parameter types (paramtype) indicated by an integer, the key name or location, value, and location (if the current POD in the query driver does not support, or -1).

This is a debugging function is used, in the case of normal output directly to the output data.

Tip: Direct and outputs the result to the browser, you can use output control functions to capture the output of the current function, and then (for example) to save a string in.

At this moment only the print parameters in the statement. Additional parameters are not stored in the statement, it will not be output.


return value

No return value.


Examples

Examples PDOStatement :: debugDumpParams () use named parameters

<?php
/* 通过绑定 PHP 变量执行一条预处理语句 */
$calories = 150;
$colour = 'red';
$sth = $dbh->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

PDOStatement :: debugDumpParams () using the example of an unnamed parameter

<?php

/* 通过绑定 PHP 变量执行一条预处理语句 */
$calories = 150;
$colour = 'red';
$name = 'apple';

$sth = $dbh->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 PHP PDO Reference Manual