新聞中心
在用PHP結(jié)合MySQL數(shù)據(jù)庫開發(fā)應(yīng)用程序時,可能會用到數(shù)據(jù)庫中全部表信息。本文主要介紹了PHP獲取所有表信息的實(shí)現(xiàn)代碼,希望能對讀者有所幫助。

椒江網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站設(shè)計(jì)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)公司2013年至今到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。
代碼如下:
- function list_tables($database)
- {
- $rs = mysql_list_tables($database);
- $tables = array();
- while ($row = mysql_fetch_row($rs)) {
- $tables[] = $row[0];
- }
- mysql_free_result($rs);
- return $tables;
- }
但由于mysql_list_tables方法已經(jīng)過時,運(yùn)行以上程序時會給出方法過時的提示信息,如下:
復(fù)制代碼 代碼如下:
- Deprecated: Function mysql_list_tables() is deprecated in … on line xxx
一個處理辦法是在php.ini中設(shè)置error_reporting,不顯示方法過時提示信息
復(fù)制代碼 代碼如下:
- error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
另一個方法是使用PHP官方推薦的替代做法:
復(fù)制代碼 代碼如下:
- function list_tables($database)
- {
- $rs = mysql_query("SHOW TABLES FROM $database");
- $tables = array();
- while ($row = mysql_fetch_row($rs)) {
- $tables[] = $row[0];
- }
- mysql_free_result($rs);
- return $tables;
- }
關(guān)于PHP獲取MySQL數(shù)據(jù)庫中所有表的代碼實(shí)現(xiàn)已經(jīng)介紹完畢了,如果您想了解更多關(guān)于MySQL數(shù)據(jù)庫的知識,可以看一下這里的文章:http://database./mysql/,相信會對您有幫助的。
【編輯推薦】
- 關(guān)于Amoeba配置文件的一點(diǎn)說明
- 利用mysql的audit審計(jì)功能記錄用戶操作信息
- MySQL索引背后的數(shù)據(jù)結(jié)構(gòu)及算法之索引實(shí)現(xiàn)
- 詳解Discuz_WIN7_Apache_MySQL_PHP平臺搭建
- MySQL錯誤:Can't connect to MySQL server (10060)
網(wǎng)頁名稱:PHP如何獲取MySQL數(shù)據(jù)庫中的所有表
網(wǎng)頁URL:http://m.fisionsoft.com.cn/article/dhdihoe.html


咨詢
建站咨詢
