Skip site navigation (1) Skip section navigation (2)

PHP and PostgreSQL boolean data type

From: Thom Brown <thombrown(at)gmail(dot)com>
To: pgsql-php(at)postgresql(dot)org, PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: PHP and PostgreSQL boolean data type
Date: 2010-02-10 12:04:23
Message-ID: bddc86151002100404o76e1acc9r469d82a49284b7b5@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-php
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?

Thanks

Thom

Responses

pgsql-php by date

Next:From: A. KretschmerDate: 2010-02-10 12:11:42
Subject: Re: PHP and PostgreSQL boolean data type
Previous:From: Gustavo Amarilla SantacruzDate: 2010-02-02 00:54:33
Subject: Re: Undefined function pg_connect()

pgsql-general by date

Next:From: A. KretschmerDate: 2010-02-10 12:11:42
Subject: Re: PHP and PostgreSQL boolean data type
Previous:From: A. KretschmerDate: 2010-02-10 11:43:55
Subject: Re: 8.5devel: unexpected and illogical error during transaction, but transaction don't rolled back

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group