Home > Backend Development > PHP Tutorial > MySQL data table is damaged. PHP obtains the implementation code of all tables in the MySQL database.

MySQL data table is damaged. PHP obtains the implementation code of all tables in the MySQL database.

WBOY
Release: 2016-07-29 08:46:00
Original
1172 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;
}


But since the mysql_list_tables method is obsolete, when running the above program, the method will be outdated. The prompt information is as follows:

Copy the code The code is as follows:


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


One solution is to set error_reporting in php.ini without displaying the method. Outdated prompt information

Copy codeThe code is as follows:


error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED


Another method is to use the alternative recommended by PHP official:

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;
}

The above introduces the implementation code of MySQL data table damage using PHP to obtain all tables in the MySQL database, including the content of MySQL data table damage. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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