具体分析PHP获得所有数据库方法
在
要查询系统中都存在哪些数据库,可使用mysql_list_dbs()函数,其语法格式如下:
resource mysql_list_dbs ([ resource $link_identifier ] )
mysql_list_dbs()函数返回的结果集中包含了MySQL服务器中所有的数据库,PHP获得所有数据库示例如下:
- ?php
-
$connection=mysql_connect("localhost","root"
,"root") or die("连接服务器失败"); - $db_list = mysql_list_dbs($connection);
-
while ($row = mysql_fetch_object
($db_list)) { - echo $row->Database . " br>";
- echo " hr>";
- }
- mysql_close($connection);
- ?>
在上面PHP获得所有数据库代码中,循环输出结果集时用到了mysql_fetch_object()函数,mysql_fetch_object()函数和mysql_fetch_array()函数用法类似,不同的是 mysql_fetch_array()函数返回一个数组,而mysql_fetch_object()函数则返回一个对象。 mysql_fetch_object()函数的语法格式如下:
object mysql_fetch_object ( resource $result )

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)
