PHP: mysql_field_table - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysql_field_type mysql_field_seek

Last updated: Fri, 26 Jan 2007

view this page in

# 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 User Contributed Notes
mysql_field_table
spam at blondella dot de
03-Oct-2006 04:09
`<?php
/*
this function might help in the case described above :-)
*/
function mysql_field_table_resolve_alias($inQuery,$inResult,$inFieldName) {
$theNameOrAlias = mysql_field_table($inResult,$inFieldName);
//check, if AS syntax is being used
if(ereg(" AS ",$inQuery)) {
//catch words in query
$theWords = explode(" ",ereg_replace(",|\n"," ",$inQuery));
//find the words preceding and following AS
foreach($theWords as $theIndex => $theWord) {
if(trim($theWord) == "AS"
&& isset($theWords[$theIndex-1])
&& isset($theWords[$theIndex+1])
&& $theWords[$theIndex+1] == $theNameOrAlias
) {
$theNameOrAlias = $theWords[$theIndex-1];
break 1;
}
}
}
return $theNameOrAlias;
}
?>`
me at thomaskeller dot biz
23-Nov-2005 01: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
14-Aug-2004 07: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.`
add a note
mysql_field_type mysql_field_seek

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST