dbs             Thu Mar 24 07:48:23 2005 EDT

  Modified files:              
    /phpdoc/en/reference/pdo/functions  PDOStatement-bindParam.xml 
  Log:
  Document how to pass a NULL value to a prepared statement.
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml
diff -u phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml:1.3 
phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml:1.4
--- phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml:1.3    Fri Feb 
25 09:47:45 2005
+++ phpdoc/en/reference/pdo/functions/PDOStatement-bindParam.xml        Thu Mar 
24 07:48:18 2005
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
 <!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. 
-->
   <refentry id="function.PDOStatement-bindParam">
    <refnamediv>
@@ -29,7 +29,7 @@
      for databases that support such features.
     </para>
     <para>
-     For input-only variables, you can pass an array of input values to
+     For non-NULL input-only variables, you can pass an array of input values 
to
      <function>PDOStatement::execute</function> instead.
     </para>
 
@@ -68,6 +68,10 @@
           use the bitwise OR operator to set the PDO_PARAM_INPUT_OUTPUT bits
           for the <parameter>data_type</parameter> parameter.
          </para>
+         <para>
+          To pass a NULL value as an input parameter, declare the
+          PDO_PARAM_NULL constant.
+         </para>
         </listitem>
        </varlistentry>
       <varlistentry>
@@ -122,6 +126,27 @@
      </programlisting>
     </example>
 
+    <example><title>Pass a NULL value into a prepared statement</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);
+
+/* Find fruit with a NULL value in the colour column */
+$sth->bindParam(':colour', $colour, PDO_PARAM_NULL);
+
+$sth->execute();
+?>
+]]>
+     </programlisting>
+    </example>
+
     <example><title>Call a stored procedure with an INOUT parameter</title>
      <programlisting role='php'>
 <![CDATA[
@@ -137,7 +162,6 @@
      </programlisting>
     </example>
 
-
    </refsect1>
 
    <refsect1 role="seealso">

Reply via email to