mysql_field_table

(PHP 3, PHP 4, PHP 5)

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

说明

string mysql_field_table ( resource result, int field_offset )

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

为向下兼容仍然可以使用 mysql_fieldtable(),但反对这样做。


add a note add a note User Contributed Notes
me at thomaskeller dot biz
24-Nov-2005 05:15
Beware that if you upgrade to MySQL 5 from any earlier version WITHOUT dumping and reloading your data (just by keeping the binary data in MyISAM table files), you might get weird output on the "table" value for mysql_fetch_field and in this function. Weird means that the table name is randomly set or not.

This behaviour seems to popup only if the SQL query contains a ORDER BY clause. A bug is already reported:

http://bugs.mysql.com/bug.php?id=14915

To prevent the issue, dump and reload all participating tables in your query or do

CREATE TABLE tmp SELECT * FROM table;
DROP TABLE table;
ALTER TABLE tmp RENAME table;

on each one via commandline client.
cptnemo
15-Aug-2004 10:18
When trying to find table names for a (My)SQL query containing 'tablename AS alias', mysql_field_table() only returns the alias as specified in the AS clause, and not the tablename.