list all tables in a database with MySQLi

后端 未结 4 1825
梦谈多话
梦谈多话 2021-02-14 04:13

I have looked around and still can\'t find how to list all my tables in a database. is it possible with MySQLi?

Thanks.

4条回答
  •  一个人的身影
    2021-02-14 04:52

    Using PHP 5.5 or later, a simple solution is using PHP's built-in array_column() function.

    $link = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
    $listdbtables = array_column(mysqli_fetch_all($link->query('SHOW TABLES')),0);
    

提交回复
热议问题