最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 列出MySQL数据库中所有表二种方法
时间:2022-06-24 19:02:58 编辑:袖梨 来源:一聚教程网
PHP代码如下:
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方法已经过时,运行以上程序时会给出方法过时的提示信息,如下:
Deprecated: Function mysql_list_tables() is deprecated in … on line xxx
一个处理办法是在php.ini中设置error_reporting,不显示方法过时提示信息
1 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;
相关文章
- 如鸢新活动游春集远房亲戚攻略 低配置无核爆通关攻略 08-03
- 燕云十六声免费外观攻略 最难拿到的三个免费套怎么拿 08-03
- 《弧光突袭者》 Arc Raiders “往昔药方”任务攻略 08-03
- 虚无世界宝宝技能搭配攻略(发掘宝宝技能的无限可能) 08-03
- 颠覆认知 曝PS6双机型定价悬殊 多数玩家恐难承受 08-03
- 《盾勇队长技能更换攻略》(优化战斗力,拓展战术选择,走上巅峰之路) 08-03