php-doc-en/reference/pdo/pdostatement/debugdumpparams.xml
Pieter Hordijk 53b3265387 Fixed E_ENGRISH / typos
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@336630 c90b9560-bf6c-de11-be94-00142212c4b1
2015-04-23 08:59:26 +00:00

166 lines
3.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pdostatement.debugdumpparams" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>PDOStatement::debugDumpParams</refname>
<refpurpose>
Dump an SQL prepared command
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>PDOStatement::debugDumpParams</methodname>
<void />
</methodsynopsis>
<para>
Dumps the information contained by a prepared statement directly on the
output. It will provide the <literal>SQL</literal> query in use, the
number of parameters used (<literal>Params</literal>), the list
of parameters with their key name or position, their name, their position
in the query (if this is supported by the PDO driver, otherwise, it will
be -1), type (<literal>param_type</literal>) as an integer, and a boolean
value <literal>is_param</literal>.
</para>
<para>
This is a debug function, which dumps the data directly to the normal
output.
&tip.ob-capture;
</para>
<para>
This will only dump the parameters in the statement at the moment
of the dump. Extra parameters are not stored in the statement,
and not displayed.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>PDOStatement::debugDumpParams</function> example with named parameters</title>
<programlisting role="php">
<![CDATA[
<?php
/* Execute a prepared statement by binding PHP variables */
$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();
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
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
]]>
</screen>
</example>
<example>
<title><function>PDOStatement::debugDumpParams</function> example with unnamed parameters</title>
<programlisting role="php">
<![CDATA[
<?php
/* Execute a prepared statement by binding PHP variables */
$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();
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
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
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>PDO::prepare</function></member>
<member><function>PDOStatement::bindParam</function></member>
<member><function>PDOStatement::bindValue</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->