|
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)過時(shí),運(yùn)行以上程序時(shí)會(huì)給出方法過時(shí)的提示信息,如下:
復(fù)制代碼 代碼如下:
Deprecated: Function mysql_list_tables() is deprecated in … on line xxx
一個(gè)處理辦法是在php.ini中設(shè)置error_reporting,不顯示方法過時(shí)提示信息
復(fù)制代碼 代碼如下:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
另一個(gè)方法是使用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;
}
php技術(shù):PHP 獲取MySQL數(shù)據(jù)庫里所有表的實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。