I am adding some functionality to a php/postgres based system and have a value that I want to be a boolean. digging around the pg doc I see the boolean datatype. Cool I say. So I happily alter the table and add the boolean column notify all is good until I retrieve it using pg_fetch_object and get a t or f back in myobject->notify
Rats says I. a simple if ($myobject->notify) { blah } contruct won't work.
So.. after reading a lot of stuff from both the php and pg doc and STFW until my eyes are tired, I am coming to you guys for advice.
Assumption: There is no easy way to map a pg boolean data type to a value that will evaluate simply in php. I know I can code it but I would really like to keep this as simple as possible
Question: Assuming the above assumption is correct, what is the most efficient way to define a column that will take only two values who's values will evaluate as intended in php?
I am going to punt an go with a smallint unlet there is a way to store a bit. I am trying to get my head around bytea right now but thought I would ask while I am reading.
Bret
Personally I would go with the smallint - but another option you have, if you really want to use their boolean, is leaving the boolean and always selecting it as:
SELECT (boolean_field = 't') AS boolean_field FROM table;
of course, using a smallint will work 'universally' if you ever changed databases - which may or may not be of interest.
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php