When selecting from a MySQL table in PHP the results are always strings. Is there a way to get the correct datatype already?
Consider my table:
CREATE TABLE bar(
id INT,
price FLOAT,
name VARCHAR(40));
Now what i have to do is:
$result = mysql_query("SELECT id,price,name FROM bar");
while($row = mysql_fetch_assoc($result))
{
$row['id'] = (int)$row['id'];
$row['price'] = (double)$row['price'];
}
mysql_free_result($result);
Is there a way to get the data-types correctly from the query transparently?
10x,
Aviv
No, all data that comes from mysql is a string actually and you cannot do anything with it.