I have a table in mysql:
CREATE TABLE user (id INT, name VARCHAR(250));
I query the table:
$result = mysql_query("SELECT id,name FROM user");
I gather the results:
while($row = mysql_fetch_assoc($result) $rv[] = $row;
And I return the data:
echo json_encode($rv);
The problem is that the id returns as string and not int, even before the json_encode. If i force $row[‘id’] = (int)$row[‘id’]; – it works fine.
How can i force mysql to return the correct data type in the $row?
10x.
PDO->bindColumn can this
$intVar will be automatically converted to int