georg           Fri Aug 22 08:08:49 2003 EDT

  Modified files:              
    /phpdoc/en/reference/mysqli/functions       mysqli-affected-rows.xml 
  Log:
  minor fixed. Added and corrected samples
  
  
Index: phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml
diff -u phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.7 
phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.8
--- phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml:1.7   Wed Jun 11 
09:00:48 2003
+++ phpdoc/en/reference/mysqli/functions/mysqli-affected-rows.xml       Fri Aug 22 
08:08:49 2003
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
   <refentry id="function.mysqli-affected-rows">
    <refnamediv>
     <refname>mysqli_affected_rows</refname>
@@ -9,7 +9,7 @@
     <title>Description</title>
      <methodsynopsis>
       <type>mixed</type><methodname>mysqli_affected_rows</methodname>
-      <methodparam><type>resource</type><parameter>link</parameter></methodparam>
+      <methodparam><type>object</type><parameter>link</parameter></methodparam>
      </methodsynopsis>
     <para>
      <function>mysqli_affected_rows</function> returns the number of rows affected by 
the last
@@ -30,52 +30,96 @@
     <para>
      <example>
       <title>Delete-Query</title>
+      <para>Procedural style:</para>
       <programlisting role="php">
 <![CDATA[
 <?php
     /* connect to database */
-    mysqli_connect("localhost", "mysql_user", "mysql_password") or
-        die("Could not connect: " . mysqli_error());
-    mysqli_select_db("mydb");
+    $link = mysqli_connect("localhost", "mysql_user", "mysql_password", "mydb") or
+        die("Could not connect: " . mysqli_connect_error());
     
     /* this should return the correct numbers of deleted records */
-    mysqli_query("DELETE FROM mytable WHERE id < 10");
-    printf ("Records deleted: %d\n", mysqli_affected_rows());
+    mysqli_query($link, "DELETE FROM mytable WHERE id < 10");
+    printf ("Records deleted: %2d\n", mysqli_affected_rows($link));
 
     /* without a where clause in a delete statement, it should return 0 */
-    mysqli_query("DELETE FROM mytable");
-    printf ("Records deleted: %d\n", mysqli_affected_rows());
+    mysqli_query($link, "DELETE FROM mytable");
+    printf ("Records deleted: %2d\n", mysqli_affected_rows($link));
+
+    /* close connection */
+    mysqli_close($link);
+?>
+]]>
+      </programlisting>
+      <para>Object oriented style:</para>
+      <programlisting>
+<![CDATA[
+<?php
+    /* connect to database */
+    $mysql = mysqli_connect("localhost", "mysql_user", "mysql_password", "mydb") or
+        die("Could not connect: " . mysqli_connect_error());
+    
+    /* this should return the correct numbers of deleted records */
+    $mysql->query("DELETE FROM mytable WHERE id < 10");
+    printf ("Records deleted: %2d\n", $mysql->affected_rows());
+
+    /* without a where clause in a delete statement, it should return 0 */
+    $mysql->query("DELETE FROM mytable");
+    printf ("Records deleted: %2d\n", $mysql->affected_rows());
+
+    /* close connection */
+    $mysql->close();
 ?>
 ]]>
       </programlisting>
       <para>
-       The above example would produce the following output:
+       The above examples would produce the following output:
        <screen>
 <![CDATA[
 Records deleted: 10
-Records deleted: 0
+Records deleted:  0
 ]]>
        </screen>
       </para>
      </example>
      <example>
       <title>Update-Query</title>
+      <para>Procedural style:</para>
       <programlisting role="php">
 <![CDATA[
 <?php
     /* connect to database */
-    mysqli_connect("localhost", "mysql_user", "mysql_password") or
-        die("Could not connect: " . mysqli_error());
-    mysqli_select_db("mydb");
+    $link = mysqli_connect("localhost", "mysql_user", "mysql_password", "mydb") or
+        die("Could not connect: " . mysqli_connect_error());
         
     /* Update records */
-    mysqli_query("UPDATE mytable SET used=1 WHERE id < 10");
-    printf ("Updated records: %d\n", mysqli_affected_rows());
+    mysqli_query($link, "UPDATE mytable SET used=1 WHERE id < 10");
+    printf ("Updated records: %d\n", mysqli_affected_rows($link));
+
+    /* close connection */
+    mysqli_close($link);
+?>
+]]>
+      </programlisting>
+      <para>Object oriented style:</para>
+      <programlisting role="php">
+<![CDATA[
+<?php
+    /* connect to database */
+    $mysql = mysqli_connect("localhost", "mysql_user", "mysql_password", "mydb") or
+        die("Could not connect: " . mysqli_connect_error());
+        
+    /* Update records */
+    $mysql->query("UPDATE mytable SET used=1 WHERE id < 10");
+    printf ("Updated records: %d\n", $mysql->affected_rows($link));
+
+    /* close connection */
+    mysql->close($link);
 ?>
 ]]>
       </programlisting>
       <para>
-       The above example would produce the following output:
+       The above examples would produce the following output:
        <screen>
 <![CDATA[
 Updated Records: 10
@@ -83,6 +127,10 @@
        </screen>
       </para>
      </example> 
+    </para>
+    <para>
+     See also: <function>mysqli_num_rows</function>,
+     <function>mysqli_info</function>.
     </para>
    </refsect1>
   </refentry>


Reply via email to