pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-php@postgresql.org
Subject: Re: PHP and PostgreSQL boolean data type
Date: 12 Feb 2010 09:13:54 GMT
Message-ID: <hl364i$16m$3@reversiblemaps.ath.cx> (raw)
References: <bddc86151002100404o76e1acc9r469d82a49284b7b5@mail.gmail.com>

On 2010-02-10, Thom Brown <thombrown@gmail.com> wrote:
> Hi,
>
> A long-standing problem we've had with PostgreSQL queries in PHP is
> that the returned data for boolean columns is the string 'f' instead
> of the native boolean value of false.
>
> An obvious example of this would be for a table with users and their
> boolean registered status:
>
> Select user, registered From users;
>
> Then getting a row from the result would reveal: array('user' =>
> 'thomb', registered => 'f');
>
> Another problem is with arrays, where they are difficult to parse as
> they also come through as plain strings with no binary alternative.
>
>  Is this a limitation of libpq or a flawed implementation in the php
> library?  And if this is just the case for backwards-compatibility, is
> there a way to switch it to a more sensible PHP data type?

cast to integer when selecting and to boolean when writing?




view thread (8+ messages)

Message-ID: <hl364i$16m$3@reversiblemaps.ath.cx>
Permalink:  ../hl364i$16m$3@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/hl364i$16m$3@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: jasen@xnet.co.nz
  Subject: Re: PHP and PostgreSQL boolean data type
  In-Reply-To: <hl364i$16m$3@reversiblemaps.ath.cx>
  References: <bddc86151002100404o76e1acc9r469d82a49284b7b5@mail.gmail.com> <hl364i$16m$3@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox