如何在php中找到mysql中一个字段的真实表名?

如何在php中找到mysql中一个字段的真实表名?

问题描述:

I have this query in my PHP code:

SELECT usr.user_id,online.online_totime
 FROM users AS usr
 LEFT JOIN online_users AS online ON online.online_user=usr.user_id

I want to find tables in this query with PHP. I use mysql_field_table and it returns "usr" and "online" as table names: those are not the real names. How I can find real table names of fields?

This query only is an example. Please don't advise me not to use AS synonym.

我在PHP代码中有这个查询: p>

  SELECT  usr.user_id,online.online_totime 
 FROM users AS usr 
 LEFT JOIN online_users AS online ON online.online_user = usr.user_id 
  code>  pre> 
 
 

我想查找表格 在这个使用PHP的查询中。 我使用 mysql_field_table code>,它返回“usr”和“online”作为表名:那些不是真名。 如何找到字段的真实表名? p>

此查询仅作为示例。 请不要告诉我不要使用 AS同义词 code>。 p> div>

You could parse the query, as one commenter of the php.net documentation suggests.