Detailed analysis of PHP methods to obtain all databases_PHP tutorial

WBOY
Release: 2016-07-15 13:35:05
Original
1056 people have browsed it

In

to query which databases exist in the system, you can use the mysql_list_dbs() function, the syntax format is as follows:

resource mysql_list_dbs ([ resource $link_identifier ] )

The result set returned by the mysql_list_dbs() function contains all databases in the MySQL server. Examples of all databases obtained by PHP are as follows:

  1. < ?php
  2. $ connection=mysql_connect("localhost","root"
    ,"root") or die("Failed to connect to server");
  3. $db_list = mysql_list_dbs($connection);
  4. while ($row = mysql_fetch_object
    ($db_list)) {
  5. echo $row->Database . br>"; echo "<
  6. hr>"; } mysql_close($connection);
  7. ?>
  8. In the above PHP code to get all databases , the mysql_fetch_object() function is used when looping to output the result set. The mysql_fetch_object() function is similar to the mysql_fetch_array() function. The difference is that the mysql_fetch_array() function returns an array, while the mysql_fetch_object() function returns an object. The syntax format of 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

To query which databases exist in the system, you can use the mysql_list_dbs() function. The syntax format is as follows: resource mysql_list_dbs ([ resource $link_identifier ] ) mysql_list_dbs(...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!