note 71178 added to function.is-int

From: Date: Wed, 15 Nov 2006 07:48:55 +0000
Subject: note 71178 added to function.is-int
Groups: php.notes 
Request: Send a blank email to php-notes+get-119738@lists.php.net to get a copy of this message
Hi, I have been using PHP + MySQL for several years, but surprisingly enough I hadn't noticed that mysql_fetch_array or mysql_fetch_object do return results without preserving the "main type" of the database tables. Always, a string type is returned. I mean, I would expect that if I have defined a field as "INT (11)", the query will return a result as PHP-int (is_int($row->field) == 1), instead of a PHP-string. If the field value is of type "tynyint", I would expect still a PHP-int, if a TEXT or VARCHAR I would expect a PHP-string type, and so on... Is there a way to avoid MySQL always sending back results as PHP-string type? Right now, I have implemented a function which extracts the properties of the table field and force (casts) the type, which is not quite an elegant procedure. ---- Server IP: 130.206.1.5 Probable Submitter: 80.34.87.62 ---- Manual Page -- http://www.php.net/manual/en/function.is-int.php Edit -- https://master.php.net/note/edit/71178 Del: integrated -- https://master.php.net/note/delete/71178/integrated Del: useless -- https://master.php.net/note/delete/71178/useless Del: bad code -- https://master.php.net/note/delete/71178/bad+code Del: spam -- https://master.php.net/note/delete/71178/spam Del: non-english -- https://master.php.net/note/delete/71178/non-english Del: in docs -- https://master.php.net/note/delete/71178/in+docs Del: other reasons-- https://master.php.net/note/delete/71178 Reject -- https://master.php.net/note/reject/71178 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119738) next »