PHP reads the code for all MySQL databases and fields in the table

Source: Internet
Author: User
This article introduces the implementation of PHP to read all the libraries in the MySQL database, table fields in a piece of code, easy to use. If you need a friend, you can refer to it below.

The code is as follows:

     
     "; $db = Mysql_list_dbs ($link); while ($row = Mysql_fetch_object ($db)) {  $db _name = $row->database;  echo " database:". $db _name."". "
"; $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 "
    $row [0]:  
"; } }? >

Interested friends, you can expand the above code, not only can query the database, and table fields, but also query database version, table information, stored procedures and so on. And then write a class that can be called anywhere, even better.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.