Home > Backend Development > PHP Tutorial > PHP obtains the implementation code of all tables in the MySQL database_PHP tutorial

PHP obtains the implementation code of all tables in the MySQL database_PHP tutorial

WBOY
Release: 2016-07-21 15:26:57
Original
844 people have browsed it

Copy code The code is as follows:

function list_tables($database)
{
$rs = mysql_list_tables($database) ;
$tables = array();
while ($row = mysql_fetch_row($rs)) {
$tables[] = $row[0];
}
mysql_free_result($ rs);
return $tables;
}

However, since the mysql_list_tables method is obsolete, when running the above program, an obsolete method prompt message will be given, as follows:
Copy code The code is as follows:

Deprecated: Function mysql_list_tables() is deprecated in … on line xxx

a The solution is to set error_reporting in php.ini and not display the method obsolescence prompt message
Copy the code The code is as follows:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Another method is to use the official PHP recommended alternative:
Copy code Code As follows:

function list_tables($database)
{
$rs = mysql_query("SHOW TABLES FROM $database");
$tables = array();
while ($row = mysql_fetch_row($rs)) {
$tables[] = $row[0];
}
mysql_free_result($rs);
return $tables;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323840.htmlTechArticleCopy the code The code is as follows: function list_tables($database) { $rs = mysql_list_tables($database); $tables = array(); while ($row = mysql_fetch_row($rs)) { $tables[] = $row[0]; } mys...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template