I have a table field in a MySQL database:
userid INT(11)
So I am calling it to my page with this query:
\"SELECT userid FR
$mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, TRUE);
Try this - worked for me.
In my project I usually use an external function that "filters" data retrieved with mysql_fetch_assoc
.
You can rename fields in your table so that is intuitive to understand which data type is stored.
For example, you can add a special suffix to each numeric field:
if userid
is an INT(11)
you can rename it userid_i
or if it is an UNSIGNED INT(11)
you can rename userid_u
.
At this point, you can write a simple PHP function that receive as input the associative array (retrieved with mysql_fetch_assoc
), and apply casting to the "value" stored with those special "keys".
MySQL has drivers for many other languages, converting data to string "standardizes" data and leaves it up to the user to type-cast values to int or others