Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 882DD632759 for ; Fri, 12 Feb 2010 05:14:11 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 73517-07 for ; Fri, 12 Feb 2010 09:13:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ananke.wxnz.net (ananke.wxnz.net [58.28.4.122]) by mail.postgresql.org (Postfix) with ESMTP id CC3DD632230 for ; Fri, 12 Feb 2010 05:14:00 -0400 (AST) Received: from gonzo (ip-118-90-132-86.xdsl.xnet.co.nz [118.90.132.86]) by ananke.wxnz.net (Postfix) with ESMTP id 1EDE9170847 for ; Fri, 12 Feb 2010 22:13:57 +1300 (NZDT) Received: from news by gonzo with local (Exim 4.69) (envelope-from ) id 1Nfrb1-0000Mv-46 for pgsql-php@postgresql.org; Fri, 12 Feb 2010 22:13:55 +1300 To: pgsql-php@postgresql.org Path: not-for-mail From: Jasen Betts Newsgroups: gmane.comp.db.postgresql.php,gmane.comp.db.postgresql.general Subject: Re: PHP and PostgreSQL boolean data type Date: 12 Feb 2010 09:13:54 GMT Organization: Dis (not Dat) Organisation Lines: 24 Message-ID: References: NNTP-Posting-Host: localhost Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reversiblemaps.ath.cx 1265966034 1238 127.0.0.1 (12 Feb 2010 09:13:54 GMT) X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-2 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.299 tagged_above=-10 required=5 tests=AWL=-0.300, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/7 X-Sequence-Number: 4127 On 2010-02-10, Thom Brown 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?