mysql_field_table

(PHP 4, PHP 5)

mysql_field_table取得指定字段所在的表名

警告

本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLiPDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:

说明

mysql_field_table(resource$result, int$field_offset): string

返回指定字段所在的表名。

参数

result

resource 型的结果集。此结果集来自对 mysql_query() 的调用。

field_offset

数值型字段偏移量。 field_offset0 开始。如果 field_offset 不存在,则会发出一个 E_WARNING 级别的错误

返回值

The name of the table on success.

示例

示例 #1 mysql_field_table() 示例

<?php

$query
= "SELECT account.*, country.* FROM account, country WHERE country.name = 'Portugal' AND account.country_id = country.id";

// get the result from the DB
$result = mysql_query($query);

// Lists the table name and then the field name
for ($i = 0; $i < mysql_num_fields($result); ++$i) {
$table = mysql_field_table($result, $i);
$field = mysql_field_name($result, $i);

echo
"$table: $field\n";
}

?>

注释

注意:

为了向下兼容,可以使用下列已废弃的别名: mysql_fieldtable()

参见

To Top