Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1552D475C26 for ; Mon, 4 Nov 2002 12:34:53 -0500 (EST) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id AD646475BA1 for ; Mon, 4 Nov 2002 12:34:50 -0500 (EST) Received: (qmail 13537 invoked by uid 0); 4 Nov 2002 17:34:52 -0000 Received: from pd9e1570f.dip.t-dialin.net (HELO teslaVM.zeggnet.de) (217.225.87.15) by mail.gmx.net (mp010-rz3) with SMTP; 4 Nov 2002 17:34:52 -0000 From: Jascha Schubert To: "scott.marlowe" Subject: Re: Booleans Date: Mon, 4 Nov 2002 18:35:24 +0100 User-Agent: KMail/1.5 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200211041835.24152.JTSMailing@gmx.net> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/7 X-Sequence-Number: 1589 Am Monday 04 November 2002 17:26 schrieb scott.marlowe: > On Mon, 4 Nov 2002, Jascha Schubert wrote: > > Hi, > > I've written an php script with many queries like > > > > "insert into table (a,b,c) VALUES('$q','$w','$e')" > > > > where $q,$w and $e are booleans. I've written it with mysql and it works > > fine there, now I want to use it with postgres and have the following > > problem: As type for a,b and c I used the bit type with length 1. Now if > > $q is true there is now problem it evaluates to '1', but false evaluates > > to '' and postgres then complains that the bit string length does not > > match. Its clearly why it happens, but is there an easy way to fix this, > > without rewriting all the sql queries with something like if($q===false) > > $q='0';. > > I'd recommend taking off your mysql thinking cap for this one. :-) > > To set your values, I'd suggest using the TRUE and FALSE method, like so: > > insert into table (a,b,c) values (TRUE,FALSE,FALSE) > > So that you use PHP to set each field to TRUE or FALSE (note there's no ' > marks around the TRUE or FALSE). The Problem is I use variables ($q) then i would have to to something like this for every querie if ($q) $q1="TRUE"; else $q1="FALSE"; ...... (also for $w and $e) "insert into table (a,b,c) VALUES($q1,$w1,$e1)" that would be much writing and makes the code more complicated. I will only do that if there is now possibility to manage this in the database. It would just need something that lets '' become to '0' for this fields. Jascha