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:
- < ?php
- $ connection=mysql_connect("localhost","root"
,"root") or die("Failed to connect to server"); - $db_list = mysql_list_dbs($connection);
- while ($row = mysql_fetch_object
($db_list)) { - echo $row->Database . br>"; echo "<
- hr>"; } mysql_close($connection);
- ?>
-
-
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(...
Statement: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