mysql_tablename

(PHP 4, PHP 5)

mysql_tablename取得表名

警告

本擴(kuò)展自 PHP 5.5.0 起已廢棄,并在自 PHP 7.0.0 開始被移除。應(yīng)使用 MySQLiPDO_MySQL 擴(kuò)展來替換之。參見 MySQL:選擇 API 指南來獲取更多信息。用以替代本函數(shù)的有:

  • SQL Query: SHOW TABLES

說明

mysql_tablename(resource $result, int $i): string|false

result 中取得表名。

此函數(shù)已廢棄,推薦使用 mysql_query() 函數(shù)來執(zhí)行 SQL SHOW TABLES [FROM db_name] [LIKE 'pattern'] 替代。

參數(shù)

result

接受 mysql_list_tables() 返回的結(jié)果指針以及一個整數(shù)索引作為參數(shù)并返回表名。

i

The integer index (row/table number)

返回值

成功時返回表名 或者在失敗時返回 false

Use the mysql_tablename() function to traverse this result pointer, or any function for result tables, such as mysql_fetch_array().

更新日志

版本 說明
5.5.0 mysql_tablename() 函數(shù)已廢棄,調(diào)用時會拋出 E_DEPRECATED 級別的錯誤。

范例

示例 #1 mysql_tablename() example

<?php
mysql_connect
("localhost""mysql_user""mysql_password");
$result mysql_list_tables("mydb");
$num_rows mysql_num_rows($result);
for (
$i 0$i $num_rows$i++) {
    echo 
"Table: "mysql_tablename($result$i), "\n";
}

mysql_free_result($result);
?>

注釋

注意:

The mysql_num_rows() function may be used to determine the number of tables in the result pointer.

參見