最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 列出MySQL数据库中所有表二种方法
时间:2011-05-10 编辑:简简单单 来源:一聚教程网
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;
-
下一个: ruby cookie用法
相关文章
- php与mysql数据库通信三步曲 03-30
- ThinkPHP框架调用mysql数据库数据例子 07-04
- php实现mysql数据库随机重排例子 10-16
- PHP操作MySQL数据库的常用方法 06-25
- php查找mysql数据库中的所有表名 04-23
- Mysql数据库操作(php教程四) 11-01