dbs Wed Apr 20 17:16:42 2005 EDT
Modified files:
/phpdoc/en/reference/ibm_db2/functions db2-bind-param.xml
Log:
First stab at db2_bind_param() documentation.
http://cvs.php.net/diff.php/phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml
diff -u phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.1
phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.2
--- phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml:1.1 Tue Apr
12 17:12:48 2005
+++ phpdoc/en/reference/ibm_db2/functions/db2-bind-param.xml Wed Apr 20
17:16:41 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc.
-->
<refentry id="function.db2-bind-param">
<refnamediv>
@@ -13,15 +13,23 @@
<methodsynopsis>
<type>bool</type><methodname>db2_bind_param</methodname>
<methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
- <methodparam><type>long</type><parameter>param_no</parameter></methodparam>
- <methodparam><type>string</type><parameter>varname</parameter></methodparam>
- <methodparam
choice="opt"><type>long</type><parameter>param_type</parameter></methodparam>
- <methodparam
choice="opt"><type>long</type><parameter>data_type</parameter></methodparam>
+
<methodparam><type>long</type><parameter>parameter-number</parameter></methodparam>
+
<methodparam><type>string</type><parameter>variable-name</parameter></methodparam>
+ <methodparam
choice="opt"><type>long</type><parameter>parameter-type</parameter></methodparam>
+ <methodparam
choice="opt"><type>long</type><parameter>data-type</parameter></methodparam>
<methodparam
choice="opt"><type>long</type><parameter>precision</parameter></methodparam>
<methodparam
choice="opt"><type>long</type><parameter>scale</parameter></methodparam>
</methodsynopsis>
- &warn.undocumented.func;
+ &warn.experimental.func;
+
+ <para>
+ Binds a PHP variable to an SQL statement parameter in a statement resource
+ returned by <function>db2_prepare</function>. This function gives you more
+ control over the parameter type, data type, precision, and scale for the
+ parameter than simply passing the variable as part of the optional input
+ array to <function>db2_execute</function>.
+ </para>
</refsect1>
<refsect1 role="parameters">
@@ -30,122 +38,118 @@
<variablelist>
<varlistentry>
<term><parameter>stmt</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>param_no</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>varname</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>param_type</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>data_type</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
+ <listitem>
+ <para>
+ A prepared statement returned from <function>db2_prepare</function>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>parameter-number</parameter></term>
+ <listitem>
+ <para>
+ Specifies the 1-indexed position of the parameter in the prepared
+ statement.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>variable-name</parameter></term>
+ <listitem>
+ <para>
+ A string specifying the name of the PHP variable to bind to the
+ parameter specified by <parameter>parameter-number</parameter>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>parameter-type</parameter></term>
+ <listitem>
+ <para>
+ A constant specifying whether the PHP variable should be bound to the
+ SQL parameter as an input parameter (<literal>DB2_PARAM_IN</literal>),
+ an output parameter (<literal>DB2_PARAM_OUT</literal>), or as a
+ parameter that accepts input and returns output
+ (<literal>DB2_PARAM_INOUT</literal>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>data-type</parameter></term>
+ <listitem>
+ <para>
+ A constant specifying the SQL data type that the PHP variable should be
+ bound as: one of <literal>DB2_BINARY</literal>,
+ <literal>DB2_CHAR</literal>, <literal>DB2_DOUBLE</literal>, or
+ <literal>DB2_LONG</literal> .
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><parameter>precision</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
+ <listitem>
+ <para>
+ Specifies the precision with which the variable should be bound to the
+ database.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><parameter>scale</parameter></term>
- <listitem>
- <para>
- Its description
- </para>
- </listitem>
- </varlistentry>
+ <listitem>
+ <para>
+ Specifies the scale with which the variable should be bound to the
+ database.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- What the function returns, first on success, then on failure. See
- also the &return.success; entity
- </para>
- </refsect1>
-
- <!-- Use when EXCEPTIONS exist
- <refsect1 role="exceptions">
- &reftitle.exceptions;
- <para>
- When does this function throw exceptions?
- </para>
- </refsect1>
- -->
-
-
- <!-- Use when a CHANGELOG exists
- <refsect1 role="changelog">
- &reftitle.changelog;
- <para>
- <informaltable>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>&Version;</entry>
- <entry>&Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>Enter the PHP version of change here
- <entry>Description of change
- </row>
- </tbody>
- </tgroup>
- </informaltable>
+ &return.success;
</para>
</refsect1>
- -->
-
- <!-- Use when examples exist
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
- <title>A <function>db2_bind_param</function> example</title>
+ <title>Binding PHP variables to a prepared statement</title>
<para>
- Any text that describes the purpose of the example, or
- what goes on in the example should go here (inside the
- <example> tag, not out
+ The SQL statement in the following example uses two input parameters in
+ the WHERE clause. We call <function>db2_bind_param</function> to bind two
+ PHP variables to the corresponding SQL parameters. Notice that the PHP
+ variables do not have to be declared or assigned before the call to
+ <function>db2_bind_param</function>; in the example,
+ <literal>$lower_limit</literal> is assigned a value before the call to
+ <function>db2_bind_param</function>, but <literal>$upper_limit</literal>
+ is assigned a value after the call to
+ <function>db2_bind_param</function>. The variables must be bound and, for
+ parameters that accept input, must have any value assigned, before calling
+ <function>db2_execute</function>.
</para>
<programlisting role="php">
<![CDATA[
<?php
-if ($anexample === true) {
- echo 'Use the PEAR Coding Standards';
+
+$sql = 'SELECT name, breed, weight FROM animals
+ WHERE weight > ? AND weight < ?';
+$conn = db2_connect($database, $user, $password);
+$stmt = db2_prepare($conn, $sql);
+
+$lower_limit = 1;
+
+db2_bind_param($stmt, 1, "lower_limit", DB2_PARAM_IN);
+db2_bind_param($stmt, 2, "upper_limit", DB2_PARAM_IN);
+$upper_limit = 15.0;
+
+$result = db2_execute($stmt);
+
+while ($row = db2_fetch_into($result)) {
+ print "{$row[0]}, {$row[1]}, {$row[2]}\n";
}
?>
]]>
@@ -153,27 +157,24 @@
&example.outputs;
<screen>
<![CDATA[
-Use the PEAR Coding Standards
+Pook, cat, 3.2
+Rickety Ride, goat, 9.7
+Peaches, dog, 12.3
]]>
</screen>
</example>
</para>
</refsect1>
- -->
-
- <!-- Use when adding See Also links
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
- <member><function></function></member>
- <member>Or <link linkend="somethingelse">something else</link></member>
+ <member><function>db2_execute</function></member>
+ <member><function>db2_prepare</function></member>
</simplelist>
</para>
</refsect1>
- -->
-
</refentry>