downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/pdostatement.debugdumpparams.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/class.pdostatement.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'pdostatement.debugdumpparams.php',
   
1 => 'PDOStatement->debugDumpParams',
  ),
 
'up' =>
  array (
   
0 => 'class.pdostatement.php',
   
1 => 'The PDOStatement class',
  ),
 
'prev' =>
  array (
   
0 => 'pdostatement.columncount.php',
   
1 => 'PDOStatement->columnCount',
  ),
 
'next' =>
  array (
   
0 => 'pdostatement.errorcode.php',
   
1 => 'PDOStatement->errorCode',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="pdostatement.debugdumpparams" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDOStatement-&gt;debugDumpParams</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PECL pdo &gt;= 0.9.0)</p><p class="refpurpose"><span class="refname">PDOStatement-&gt;debugDumpParams</span> &mdash; <span class="dc-title">
   Dump a SQL prepared command
  </span></p>

 </div>
 <a name="pdostatement.debugdumpparams.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>PDOStatement::debugDumpParams</b></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Dumps the informations contained by a prepared statement directly on the
   output. It will provide the <i>SQL</i> query in use, the
   number of parameters used (<i>Params</i>), the list
   of parameters, with their name, type (<i>paramtype</i>) as
   an integer, their key name or position, the value, and the position
   in the query (if this is supported by the PDO driver, otherwise, it will
   be -1).
  </p>
  <p class="para">
   This is a debug function, which dump directly the data on the normal
   output.
   <div class="tip"><b class="tip">Tip</b><p class="simpara">As with anything that outputs
its result directly to the browser, the <a href="ref.outcontrol.php" class="link">output-control functions</a> can be used to capture
the output of this function, and save it in a
<a href="language.types.string.php" class="type string">string</a> (for example).</p></div>
  </p>
  <p class="para">
   This will only dumps the parameters in the statement at the moment
   of the dump. Extra parameters are not stored in the statement,
   and not displayed.
  </p>
 </div>


 <a name="pdostatement.debugdumpparams.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <a name="pdostatement.debugdumpparams.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <div class="example">
   <p><b>Example #1 <b>PDOStatement::debugDumpParams()</b> example with named parameters</b></p>
   <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Execute&nbsp;a&nbsp;prepared&nbsp;statement&nbsp;by&nbsp;binding&nbsp;PHP&nbsp;variables&nbsp;*/<br /></span><span style="color: #0000BB">$calories&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">150</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$colour&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'red'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$sth&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;colour,&nbsp;calories<br />&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;fruit<br />&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;calories&nbsp;&lt;&nbsp;:calories&nbsp;AND&nbsp;colour&nbsp;=&nbsp;:colour'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindParam</span><span style="color: #007700">(</span><span style="color: #DD0000">':calories'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$calories</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">PARAM_INT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindValue</span><span style="color: #007700">(</span><span style="color: #DD0000">':colour'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$colour</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">PARAM_STR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">debugDumpParams</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents para"><p>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
SQL: [96] SELECT name, colour, calories
    FROM fruit
    WHERE calories &lt; :calories AND colour = :colour
Params:  2
Key: Name: [9] :calories
paramno=-1
name=[9] &quot;:calories&quot;
is_param=1
param_type=1
Key: Name: [7] :colour
paramno=-1
name=[7] &quot;:colour&quot;
is_param=1
param_type=2
</pre></div>
   </div>
  </div>

  <div class="example">
   <p><b>Example #2 <b>PDOStatement::debugDumpParams()</b> example with unnamed parameters</b></p>
   <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;Execute&nbsp;a&nbsp;prepared&nbsp;statement&nbsp;by&nbsp;binding&nbsp;PHP&nbsp;variables&nbsp;*/<br /></span><span style="color: #0000BB">$calories&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">150</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$colour&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'red'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'apple'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$sth&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;colour,&nbsp;calories<br />&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;fruit<br />&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;calories&nbsp;&lt;&nbsp;?&nbsp;AND&nbsp;colour&nbsp;=&nbsp;?'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindParam</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$calories</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">PARAM_INT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bindValue</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$colour</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PDO</span><span style="color: #007700">::</span><span style="color: #0000BB">PARAM_STR</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$sth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">debugDumpParams</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents para"><p>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
SQL: [82] SELECT name, colour, calories
    FROM fruit
    WHERE calories &lt; ? AND colour = ?
Params:  2
Key: Position #0:
paramno=0
name=[0] &quot;&quot;
is_param=1
param_type=1
Key: Position #1:
paramno=1
name=[0] &quot;&quot;
is_param=1
param_type=2
</pre></div>
   </div>
  </div>

 </div>


 <a name="pdostatement.debugdumpparams.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="pdo.prepare.php" class="function" rel="rdfs-seeAlso">PDO::prepare()</a> - Prepares a statement for execution and returns a statement object</li>
    <li class="member"><a href="pdostatement.bindparam.php" class="function" rel="rdfs-seeAlso">PDOStatement::bindParam()</a> - Binds a parameter to the specified variable name</li>
    <li class="member"><a href="pdostatement.bindvalue.php" class="function" rel="rdfs-seeAlso">PDOStatement::bindValue()</a> - Binds a value to a parameter</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites