get column type from query result
Posted: Tue Jul 04, 2006 5:24 am
I want to get the data type from each mysql column in a result from an sql query in PHP.
I've included the entire piece of code so you understand exactly what I'm talking about. What I'm trying to avoid is double-querying the database; once with the query; and then again using the DESCRIBE function.
Would the PHP function gettype( ) by any chance work with the data I get from the database???
Thanks
Code: Select all
$result=$db_connection->query($sql_query);
$temp_column;
$temp_result_field=array( );
$temp_result_set=array( );
for($i=0; $i<$result->num_rows; $i++)
{
$row=$result->fetch_row( );
for($j=0; $j<sizeof($row); $j++)
{
$temp_result_field[$j]=new result_cell(stripslashes($row[$j]), <<GET DATA TYPE FROM $row[$j] HERE>>);
}
$result_set[$i] = $temp_result_field;
}Would the PHP function gettype( ) by any chance work with the data I get from the database???
Thanks