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

Re: Inserting NULL into Integer column

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Jeremy Smith <jer(at)highboard(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Inserting NULL into Integer column
Date: 2004-02-18 20:44:47
Message-ID: Pine.LNX.4.33.0402181344110.3399-100000@css120.ihs.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
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.


In response to

pgsql-hackers by date

Next:From: Rod TaylorDate: 2004-02-18 20:53:55
Subject: Re: Inserting NULL into Integer column
Previous:From: Jeremy SmithDate: 2004-02-18 20:43:13
Subject: Re: Inserting NULL into Integer column

pgsql-sql by date

Next:From: Rod TaylorDate: 2004-02-18 20:53:55
Subject: Re: Inserting NULL into Integer column
Previous:From: Jeremy SmithDate: 2004-02-18 20:43:13
Subject: Re: Inserting NULL into Integer column

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