Detailed analysis PHP get all database methods _php Tutorial

Source: Internet
Author: User
In

To query which databases exist in the system, you can use the Mysql_list_dbs () function, which has the following syntax format:

Resource Mysql_list_dbs ([Resource $link _identifier])

The result set returned by the Mysql_list_dbs () function contains all the databases in the MySQL server, and PHP obtains all the database examples as follows:

  1. < ? PHP
  2. $ Connection = mysql_connect ("localhost", "root"
    , "root") or Die ("Connection Server failed");
  3. $ db_list = Mysql_list_dbs ($connection);
  4. While ($row = mysql_fetch_object
    ($db _list)) {
  5. Echo $row- > Database. "< br>";
  6. echo " < hr>";
  7. }
  8. Mysql_close ($connection);
  9. ?>

In the above PHP get all the database code, the loop output result set used the Mysql_fetch_object () function, mysql_fetch_object () function and mysql_fetch_array () function usage similar, different is Mysql_ The Fetch_array () function returns an array, and the Mysql_fetch_object () function returns an object. The syntax format for the mysql_fetch_object () function is as follows:

Object Mysql_fetch_object (Resource $result)


http://www.bkjia.com/PHPjc/445933.html www.bkjia.com true http://www.bkjia.com/PHPjc/445933.html techarticle in order to query which databases exist in the system, you can use the Mysql_list_dbs () function, which has the following syntax: Resource Mysql_list_dbs ([Resource $link _identifier]) mysql_list _dbs ( ...

  • 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.