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
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".