Re: Bit(1) datatype from mySQL
| From: | El Bekko | Date: | Sun, 08 Jan 2006 14:35:22 +0000 |
| Subject: | Re: Bit(1) datatype from mySQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41005@lists.php.net to get a copy of this message | ||
Larry Bradley wrote:
Greetings: I'm new to PHP, although I've been a programmer all my life. I had been doing a bit of web database work with VB Script and ASP and mySQL, and then decided to try PHP. I've run into a couple of things that bother me. I have boolean fields (i.e. bit(1)) in the mySQL database. When I retrieve data from the mySQL server into an array or an object, it seems as if all the data fields are returned as characters. For most data types this does not matter, since PHP will handle them properly. This an integer 46 being retrieved as a character '46' is OK. However, the boolean is a curse, as it comes back as a character containing hex 00 or hex 01, and I have to use a test such as: if (ord(IsAMember) == 0) ... I can't just treat it as a boolean. I have got around the problem by using a construct such as: select if(IsAMember,1,0) as IsAMember in the SQL select, but this is a bit of a pain. Any thoughts? Thanks Larry Bradley Orleans (Ottawa), Ontario, CANADATry using a set() field with values true and false