Click to See Complete Forum and Search --> : mysql_fetch_field


Sid3335
08-04-2006, 03:58 AM
I'm constructing an array of values from a mysql result resource like:

for ($i=0; $i < count($row); $i++)
{
$full_db_array[] = mysql_fetch_field($result, $i) ;
}


i'm getting the column type like:

echo $full_db_array[$x]->type ;


problem is it is very generalised, for example, tinyint, smallint and int are all classed as int.

why does is not pass as the actual field type and just a general category?
is there a way to get around this?

themarty
08-04-2006, 04:53 AM
SHOW FIELDS FROM table

gives that information

Sid3335
08-04-2006, 05:04 AM
what i have is a select query:


$result = $db->query("
SELECT field1, field2, field3, field4
FROM table
WHERE field1 = 1
" ) ;


the output i require is:
COLUMN NAME || DATA TYPE || VALUE

so an example:
field1 || tinyint || 1
field2 || varchar || 'test'
field3 || int || 11

thanks