You are here: Re: Retrieving fields name from mysql « PHP Programming Language « IT news, forums, messages
Re: Retrieving fields name from mysql

Posted by Peter Fox on 04/10/06 19:54

Following on from Mike Youell's message. . .

MySql:-
Look up SHOW COLUMNS for what the database looks like.

If you want to see the field names for a live results set you can use
the flag that sets the associated name in the mysql_[err] - I'm not at
mt PHP system] fetch function and extract the keys from the array result
set.




>
>As far as I'm aware there is no way to do it accept use the "describe"
>function of mysql (or sql or whatever).
>
>You can call this using the php mysql query command. I use mysqli in
>PHP5, it becomes even easier then.
>
>I haven't tested this but try the following:
>
>// Initialise the type array to empty.
>$TypeArray = array();
>
>// Perform the mysql "describe" of the table Categories.
>$QueryResult = $this->m_mysqli->query("describe Categories");
>
>// Error checking for above function here, yada yada yada ;o)
>
>// Convert the first result into an object.
>$ResultObject = $QueryResult->fetch_object();
>
>// If there was a result then...
>while ($ResultObject !== NULL)
>{
> // Get the type...
> $Type = $ResultObject->Type;
>
> // And push it onto the type array.
> array_push($TypeArray, $Type);
>
> // Get the next result.
> $ResultObject = $QueryResult->fetch_object();
>}
>

--
PETER FOX Not the same since the cardboard box company folded
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация