How to get a list of databases?

前端 未结 4 649
醉梦人生
醉梦人生 2020-12-17 00:34

I was wondering if there\'s a way in PHP to list all available databases by usage of mysqli. The following works smooth in

4条回答
  •  悲&欢浪女
    2020-12-17 01:05

    It doesn't appear as though there's a function available to do this, but you can execute a show databases; query and the rows returned will be the databases available.

    EXAMPLE:

    Replace this:

    $db_list = mysql_list_dbs($link); //mysql 
    

    With this:

    $db_list = mysqli_query($link, "SHOW DATABASES"); //mysqli
    

提交回复
热议问题