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

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


咨詢
建站咨詢
