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>
[Back to original message]
|