mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 02:48:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@172807 c90b9560-bf6c-de11-be94-00142212c4b1
104 lines
3.2 KiB
XML
104 lines
3.2 KiB
XML
<?xml version='1.0' encoding='iso-8859-1'?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
|
|
<refentry id="function.PDOStatement-execute">
|
|
<refnamediv>
|
|
<refname>PDOStatement::execute</refname>
|
|
<refpurpose>
|
|
Executes a prepared statement
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>PDOStatement::execute</methodname>
|
|
<methodparam choice="opt"><type>array</type><parameter>input_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>PDOStatement::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 input-only parameter values</para></listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<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 < :calories AND colour = :colour');
|
|
$sth->bindParam(':calories', $calories, PDO_PARAM_INT);
|
|
$sth->bindParam(':colour', $colour, PDO_PARAM_STR, 12);
|
|
$sth->execute();
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example><title>Execute a prepared statement with an array of insert values</title>
|
|
<programlisting role='php'>
|
|
<![CDATA[
|
|
<?php
|
|
/* Execute a prepared statement by passing an array of insert values */
|
|
$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->bindParam(':colour', $colour, PDO_PARAM_STR, 12);
|
|
$sth->execute(array(':calories' => $calories, ':colour' => $colour));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<example><title>Execute a prepared statement with question mark placeholders</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>
|
|
</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:"../../../../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
|
|
-->
|