|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-07-29 10:16 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 11:00:02 2025 UTC |
I am not 100% that this is not 'working as designed', but it seems to me that if that is the case then the design needs to be looked at... When I get numeric fields from a MySQL database, they are returned as strings. This does not matter most of the time (since you are only going to pass them on to some other routine which only cares about the value, not the datatype), but occassionally causes a headache. For example, $query = "SELECT cat_key FROM category"; $result = mysql_query($query); if ($result) { while (list($cat_key) = mysql_fetch_array($result)) { $cat_keys[] = $cat_key; } } The values in the array of $cat_keys in the above example will be string, even if the $cat_key field in the database is defined as, for example, integer. Of course it is possible to force it to be numeric by making the line: $cat_keys[] = (int) $cat_key; But shouldn't PHP be making the datatype numeric for a numeric field? Thanks! Hugh Prior