simenec         Wed Oct 26 11:27:30 2005 EDT

  Modified files:              
    /phpdoc/en/reference/maxdb/functions        maxdb-stmt-bind-param.xml 
  Log:
  update documentation
  
http://cvs.php.net/diff.php/phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml
diff -u phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml:1.4 
phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml:1.5
--- phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml:1.4   Wed May 
 4 05:39:11 2005
+++ phpdoc/en/reference/maxdb/functions/maxdb-stmt-bind-param.xml       Wed Oct 
26 11:27:30 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
   <refentry id="function.maxdb-stmt-bind-param">
    <refnamediv>
     <refname>maxdb_stmt_bind_param</refname>
@@ -22,11 +22,28 @@
      <methodsynopsis>
       <type>bool</type>
        <methodname>bind_param</methodname>
-      <methodparam><type>array</type><parameter>types</parameter></methodparam>
+      
<methodparam><type>string</type><parameter>types</parameter></methodparam>
       <methodparam><type>mixed</type><parameter 
role="reference">var1</parameter></methodparam>
       <methodparam choice="opt"><type>mixed</type><parameter 
role="reference">...</parameter></methodparam>
      </methodsynopsis>
     </classsynopsis>
+    <para>Procedural style (extended syntax):</para>
+    <methodsynopsis>
+     <type>bool</type><methodname>maxdb_stmt_bind_param</methodname>
+     
<methodparam><type>resource</type><parameter>stmt</parameter></methodparam>
+     <methodparam><type>string</type><parameter>types</parameter></methodparam>
+     <methodparam><type>array</type><parameter 
role="reference">var</parameter></methodparam>
+    </methodsynopsis>
+    <para>Object oriented style (method) (extended syntax):</para>
+    <classsynopsis>
+     <ooclass><classname>stmt</classname></ooclass>
+     <methodsynopsis>
+      <type>bool</type>
+       <methodname>bind_param</methodname>
+      
<methodparam><type>string</type><parameter>types</parameter></methodparam>
+      <methodparam><type>array</type><parameter 
role="reference">var</parameter></methodparam>
+     </methodsynopsis>
+    </classsynopsis>
     <para>
      <function>maxdb_stmt_bind_param</function> is used to bind variables for 
the
      parameter markers in the SQL statement that was passed to
@@ -35,6 +52,12 @@
      the types for the corresponding bind variables.
     </para>
     <para>
+     The extended syntax of <function>maxdb_stmt_bind_param</function> allows 
to give the parameters
+     as an array instead of a variable list of PHP variables to the function. 
If the array variable has not been
+     used before calling <function>maxdb_stmt_bind_param</function>, it has to 
be initialized as an emtpy
+     array. See the examples how to use 
<function>maxdb_stmt_bind_param</function> with extended syntax.
+    </para>
+    <para>
      Variables for SELECT INTO SQL statements can also be bound using 
<function>maxdb_stmt_bind_param</function>.
      Parameters for database procedures can be bound using 
<function>maxdb_stmt_bind_param</function>. See the
      examples how to use <function>maxdb_stmt_bind_param</function> in this 
cases.
@@ -277,6 +300,79 @@
 a
 ]]>
     </screen>
+    <example>
+     <title>Object oriented style (extended syntax)</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+$maxdb = new maxdb('localhost', 'MONA', 'RED', 'DEMODB');
+
+/* check connection */
+if (maxdb_connect_errno()) {
+   printf("Connect failed: %s\n", maxdb_connect_error());
+   exit();
+}
+
+$maxdb->query ("CREATE TABLE temp.mycity LIKE hotel.city");
+$maxdb->query ("INSERT INTO temp.mycity SELECT * FROM hotel.city");
+
+$stmt = $maxdb->prepare("INSERT INTO temp.mycity VALUES (?, ?, ?)");
+
+$arr = array();
+
+$stmt->bind_param('iss', $arr);
+
+$arr[0] = 11111;
+$arr[1] = 'Georgetown';
+$arr[2] = 'NY';
+
+/* execute prepared statement */
+$stmt->execute();
+
+printf("%d Row inserted.\n", maxdb_stmt_affected_rows($stmt));
+
+$arr[0] = 22222;
+$arr[1] = 'New Orleans';
+$arr[2] = 'LA';
+
+/* execute prepared statement */
+$stmt->execute();
+
+printf("%d Row inserted.\n", $stmt->affected_rows);
+
+/* close statement and connection */
+$stmt->close();
+
+$result = $maxdb->query("SELECT * from temp.mycity WHERE zip = '11111' OR zip 
= '22222'");
+if ($result) {
+  while ($row = $result->fetch_row()) {
+    printf ("%s %s %s\n", $row[0], $row[1], $row[2]);
+  }
+}
+
+/* Clean up table CountryLanguage */
+$maxdb->query("DELETE FROM temp.mycity WHERE name='Georgetown'");
+$maxdb->query("DELETE FROM temp.mycity WHERE name='New Orleans'");
+printf("%d Rows deleted.\n", $maxdb->affected_rows);
+
+/* close connection */
+$maxdb->close();
+?>
+]]>
+     </programlisting>
+    </example>
+    <para>
+     The above examples would produce the following output:
+    </para>
+    <screen>
+<![CDATA[
+1 Row inserted.
+1 Row inserted.
+11111 Georgetown NY
+22222 New Orleans LA
+2 Rows deleted.
+]]>
+    </screen>
    </refsect1>
   </refentry>
 

Reply via email to