Re: boolean values in postgresql
| From: | Robby Russell | Date: | Wed, 23 Feb 2005 14:24:35 +0000 |
| Subject: | Re: boolean values in postgresql | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38646@lists.php.net to get a copy of this message | ||
On Mon, 2005-02-21 at 20:54 -0600, Bret Hughes wrote:
> 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
>
Couldn't you just check on 't' or 'f'?
> 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
>
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting Ruby on Rails Apps ---
****************************************/