X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 88EF6D1E144 for ; Wed, 18 Feb 2004 20:53:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 89066-01 for ; Wed, 18 Feb 2004 16:53:19 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D2C46D1E141 for ; Wed, 18 Feb 2004 16:53:16 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i1IKpUVo007299; Wed, 18 Feb 2004 13:51:30 -0700 (MST) Date: Wed, 18 Feb 2004 13:44:47 -0700 (MST) From: "scott.marlowe" To: Jeremy Smith Cc: Subject: Re: Inserting NULL into Integer column In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/261 X-Sequence-Number: 16951 On Wed, 18 Feb 2004, Jeremy Smith wrote: > > > I've run into this kind of thing before. IT helps if you have an array of > all your fields like: > > $fields = array("field1","field3","last_name"); > > and then you can foreach across the input: > > foreach($fields as $f){ > if (!$_POST[$f]){ > $_POST[$f]='DEFAULT'; > } else { > $_POST[$f] = "'".$_POST[$f]."'"; > } > } > > Wow, great idea. I will definitely do this, thanks alot. > > > > Well, you might find yourself rewriting fair portions of your site, but > usually you wind up with better code and better checking, so it's a bit of > a trade off. > > > No doubt that this is true. Of course even without the better code and > error checking, the extra features like stored procedures and automatic row > locking was more than enough to make the switch worth it. > > Thanks again! You're welcome! Enjoy getting to know Postgresql and all the great folks on the lists, I know I have.