Re: PHP and PostgreSQL boolean data type

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: PHP and PostgreSQL boolean data type
Date: 2010-02-12 09:13:54
Message-ID: hl364i$16m$3@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-php

On 2010-02-10, Thom Brown <thombrown(at)gmail(dot)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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2010-02-12 09:21:46 [SOLVED] C function to create tsquery not working
Previous Message Richard Huxton 2010-02-12 08:32:55 Re: Make sure there is no two column with same value - What is the best practice?

Browse pgsql-php by date

  From Date Subject
Next Message Steve.Toutant 2010-03-29 20:13:07 launch a php script from a trigger function
Previous Message Torsten Zühlsdorff 2010-02-11 07:42:35 Re: PHP and PostgreSQL boolean data type