mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
major update: rewrote example, returns false on failure, described the
required 'database' parameter, a little WS. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@81661 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
62658ae67e
commit
0aec7ea5cd
1 changed files with 28 additions and 12 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue