This article introduces a piece of code that uses PHP to read the fields in all libraries and tables in the MySQL database. It is simple and easy to use. Friends in need can refer to it.
The code is as follows: <?php /** * 读取Mysql数据库 表中字段 * edit bbs.it-home.org */ $link = mysql_connect('localhost','root','123456'); echo mysql_error(); echo "当前MYSQL版本:".mysql_get_server_info()."<br>"; $db = mysql_list_dbs($link); while($row = mysql_fetch_object($db)){ $db_name = $row->Database; echo "<b>数据库:".$db_name."</b>"."<br>"; $db_table = mysql_list_tables($db_name); while($row = mysql_fetch_row($db_table)){ $result = mysql_query("select * from $row[0]"); $flags=mysql_field_flags($result,0); echo "<pre class="brush:php;toolbar:false"> $row[0] : $flags <br> Copy after login Interested friends can extend the above code to not only query the database and fields in the table, but also query the database version, table information, stored procedures, etc. It would be even better to write it as a class that can be called anywhere. |