php-doc-en/reference/pdo/functions/PDOStatement-bindParam.xml
Jakub Vrana fa5fa51bfe Tidy a bit
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@172480 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-11 08:16:32 +00:00

95 lines
3 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.2 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDOStatement-bindParam">
<refnamediv>
<refname>PDOStatement::bindParam</refname>
<refpurpose>
Binds a parameter to a the specified variable name
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>PDOStatement::bindParam</methodname>
<methodparam><type>mixed</type><parameter>parameter_name</parameter></methodparam>
<methodparam><type>mixed</type><parameter role="reference">variable</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>data_type</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Binds an SQL statement parameter to the specified variable name. The SQL statement
parameter can either be a named placeholder or a question mark placeholder.
</para>
<para>
Output parameters will set the value of the bound PHP variable to the value
returned by the database when the SQL statement is executed. This enables you
to call stored procedures with output or input/output parameters, for example,
for databases that support such features.
</para>
<para>
For input-only variables, you can pass an array of input values to
<function>PDOStatement::execute</function> instead.
</para>
<example><title>Execute a prepared statement with named 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 < :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 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
-->