(PHP 4, PHP 5)
mysql_tablename — 取得表名
本擴展自 PHP 5.5.0 起已廢棄,并在自 PHP 7.0.0 開(kāi)始被移除。應使用 MySQLi 或 PDO_MySQL 擴展來(lái)替換之。參見(jiàn) MySQL:選擇 API 指南來(lái)獲取更多信息。用以替代本函數的有:
SHOW TABLES
$result
, int $i
): string|false
從 result
中取得表名。
此函數已廢棄,推薦使用
mysql_query() 函數來(lái)執行 SQL SHOW TABLES
[FROM db_name] [LIKE 'pattern']
替代。
result
接受 mysql_list_tables() 返回的結果指針以及一個(gè)整數索引作為參數并返回表名。
i
The integer index (row/table number)
成功時(shí)返回表名 或者在失敗時(shí)返回 false
。
Use the mysql_tablename() function to traverse this result pointer, or any function for result tables, such as mysql_fetch_array().
版本 | 說(shuō)明 |
---|---|
5.5.0 |
mysql_tablename() 函數已廢棄,調用時(shí)會(huì )拋出
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.