philip          Mon Mar  7 13:23:08 2005 EDT

  Modified files:              
    /phpdoc/en/reference/mysql/functions        mysql-create-db.xml 
                                                mysql-db-query.xml 
                                                mysql-drop-db.xml 
                                                mysql-list-tables.xml 
  Log:
  Added an example that replaces use of this deprecated function.
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-create-db.xml?r1=1.10&r2=1.11&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-create-db.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.10 
phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.11
--- phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.10        Fri Feb 
20 12:36:42 2004
+++ phpdoc/en/reference/mysql/functions/mysql-create-db.xml     Mon Mar  7 
13:23:07 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
 <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
   <refentry id="function.mysql-create-db">
    <refnamediv>
@@ -25,7 +25,7 @@
     </para>
     <para>
      <example>
-      <title>MySQL create database example</title>
+      <title><function>mysql_create_db</function> alternative example</title>
       <programlisting role="php">
 <![CDATA[
 <?php
@@ -34,8 +34,9 @@
     die('Could not connect: ' . mysql_error());
 }
 
-if (mysql_create_db('my_db')) {
-    echo "Database created successfully\n";
+$sql = 'CREATE DATABASE my_db';
+if (mysql_query($sql, $link)) {
+    echo "Database my_db created successfully\n";
 } else {
     echo 'Error creating database: ' . mysql_error() . "\n";
 }
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-db-query.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-db-query.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-db-query.xml:1.4 
phpdoc/en/reference/mysql/functions/mysql-db-query.xml:1.5
--- phpdoc/en/reference/mysql/functions/mysql-db-query.xml:1.4  Fri Sep  6 
09:02:32 2002
+++ phpdoc/en/reference/mysql/functions/mysql-db-query.xml      Mon Mar  7 
13:23:07 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
 <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
   <refentry id="function.mysql-db-query">
    <refnamediv>
@@ -40,6 +40,43 @@
      this function.
     </para>
     <para>
+     <example>
+      <title><function>mysql_db_query</function> alternative example</title>
+      <programlisting role="php">
+<![CDATA[
+<?php
+$dbname = 'mysql_dbname';
+
+if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
+    echo 'Could not connect to mysql';
+    exit;
+}
+
+if (!mysql_select_db($dbname, $link)) {
+    echo 'Could not select database';
+    exit;
+}
+
+$sql    = 'SELECT foo FROM bar WHERE id = 42';
+$result = mysql_query($sql, $link);
+
+if (!$result) {
+    echo "DB Error, could not list tables\n";
+    echo 'MySQL Error: ' . mysql_error();
+    exit;
+}
+
+while ($row = mysql_fetch_assoc($result)) {
+    echo $row['foo'];
+}
+
+mysql_free_result($result);
+?>
+]]>
+      </programlisting>
+     </example>
+    </para>
+    <para>
      See also <function>mysql_connect</function> and
      <function>mysql_query</function>.
     </para>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-drop-db.xml?r1=1.10&r2=1.11&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-drop-db.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-drop-db.xml:1.10 
phpdoc/en/reference/mysql/functions/mysql-drop-db.xml:1.11
--- phpdoc/en/reference/mysql/functions/mysql-drop-db.xml:1.10  Tue Sep 28 
11:33:55 2004
+++ phpdoc/en/reference/mysql/functions/mysql-drop-db.xml       Mon Mar  7 
13:23:07 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
 <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
   <refentry id="function.mysql-drop-db">
    <refnamediv>
@@ -34,6 +34,28 @@
       <literal>SQL DROP DATABASE</literal> statement instead.
      </para>
     </note>
+    <para>
+     <example>
+      <title><function>mysql_drop_db</function> alternative example</title>
+      <programlisting role="php">
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+    die('Could not connect: ' . mysql_error());
+}
+
+$sql = 'DROP DATABASE my_db';
+if (mysql_query($sql, $link)) {
+    echo "Database my_db was successfully dropped\n";
+} else {
+    echo 'Error creating database: ' . mysql_error() . "\n";
+}
+?>
+]]>
+      </programlisting>
+     </example>
+    </para>
     <warning>
      <para>
       This function will not be available
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-list-tables.xml?r1=1.12&r2=1.13&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-list-tables.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.12 
phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.13
--- phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.12      Tue Nov 
23 04:31:58 2004
+++ phpdoc/en/reference/mysql/functions/mysql-list-tables.xml   Mon Mar  7 
13:23:07 2005
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.12 $ -->
+<!-- $Revision: 1.13 $ -->
 <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
   <refentry id="function.mysql-list-tables">
    <refnamediv>
@@ -42,7 +42,7 @@
     </note>
     <para>
      <example>
-      <title><function>mysql_list_tables</function> example</title>
+      <title><function>mysql_list_tables</function> alternative example</title>
       <programlisting role="php">
 <![CDATA[
 <?php
@@ -53,7 +53,8 @@
     exit;
 }
 
-$result = mysql_list_tables($dbname);
+$sql    = "SELECT TABLES FROM $dbname";
+$result = mysql_query($sql);
 
 if (!$result) {
     echo "DB Error, could not list tables\n";
@@ -62,7 +63,7 @@
 }
 
 while ($row = mysql_fetch_row($result)) {
-    echo "Table: $row[0]\n";
+    echo "Table: {$row[0]}\n";
 }
 
 mysql_free_result($result);

Reply via email to