php-doc-en/reference/pdo/functions/pdo-execute.xml
Sean Coates 1faa1f377d fixed refentry ids
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@172447 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-10 17:37:28 +00:00

57 lines
1.8 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.3 $ -->
<refentry id='function.pdo-execute'>
<refnamediv>
<refname>execute</refname>
<refpurpose>Executes a prepared statement</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>execute</methodname>
<methodparam choice='opt'><type>array</type><parameter>parameters</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Execute the prepared statement. If the prepared statement included
parameter markers, you must either:
<itemizedlist>
<listitem><para>call <function>bindParam</function> to bind PHP variables
to the parameter markers: bound variables pass their value as input and receive the
output value, if any, of their associated parameter markers</para></listitem>
<listitem><para>or pass an array of parameter values</para></listitem>
</itemizedlist>
<example><title>Execute a prepared statement with bound variables</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 < ? AND colour = ?');
$sth->bindParam(1, $calories, PDO_PARAM_INT);
$sth->bindParam(2, $colour, PDO_PARAM_STR, 12);
$sth->execute();
?>
]]>
</programlisting>
</example>
<example><title>Execute a prepared statement by passing an array of
values</title>
<programlisting role='php'>
<![CDATA[
<?php
/* Execute a prepared statement by passing an array of values */
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->execute(array(150, 'red'));
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>