cvs: phpdoc /en/reference/mysql/functions mysql-list-tables.xml

From: Date: Fri, 10 May 2002 02:57:28 +0000
Subject: cvs: phpdoc /en/reference/mysql/functions mysql-list-tables.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969345401@lists.php.net to get a copy of this message
philip Thu May 9 22:57:28 2002 EDT Modified files: /phpdoc/en/reference/mysql/functions mysql-list-tables.xml Log: major update: rewrote example, returns false on failure, described the required 'database' parameter, a little WS. Index: phpdoc/en/reference/mysql/functions/mysql-list-tables.xml diff -u phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.3 phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.4 --- phpdoc/en/reference/mysql/functions/mysql-list-tables.xml:1.3 Sun Apr 21 11:18:45 2002 +++ phpdoc/en/reference/mysql/functions/mysql-list-tables.xml Thu May 9 22:57:28 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 --> <refentry id="function.mysql-list-tables"> <refnamediv> @@ -21,25 +21,41 @@ <function>mysql_query</function> function. You can use the <function>mysql_tablename</function> function to extract the actual table names from the result pointer, or any other result - table function. + table function such as <function>mysql_fetch_assoc</function>. </para> <para> - For downward compatibility <function>mysql_listtables</function> - can also be used. This is deprecated however. + The <parameter>database</parameter> parameter is the name of the + database to retrieve the list of tables from. Upon failure, + <function>mysql_list_tables</function> returns &false;. + </para> + <para> + For downward compatibility, the function alias named + <function>mysql_listtables</function> can be used. This is + deprecated however and is not recommended. </para> <example> <title>mysql_list_tables Example</title> - <programlisting role="php"> + <programlisting role="php"> <![CDATA[ <?php - mysql_connect("localhost", "mysql_user", "mysql_password") or - die("could not connect"); - mysql_select_db("mydb"); + $dbname = 'mysql_dbname'; - $result = mysql_list_tables(); + if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { + print 'Could not connect to mysql'; + exit; + } - while (($row = mysql_fetch_row($result)) - printf ("Table: %s\n", $row[0]); + $result = mysql_list_tables($dbname); + + if (!$result) { + print "DB Error, could not list tables\n"; + print 'MySQL Error: ' . mysql_error(); + exit; + } + + while ($row = mysql_fetch_row($result)) { + print "Table: $row[0]\n"; + } mysql_free_result($result); ?> @@ -48,7 +64,7 @@ </example> <para> See also: <function>mysql_list_dbs</function>, - <function>mysql_tablename</function>. + and <function>mysql_tablename</function>. </para> </refsect1> </refentry>

« previous php.doc (#969345401) next »