Re: Inserting NULL into Integer column - Mailing list pgsql-sql

From Jeremy Smith
Subject Re: Inserting NULL into Integer column
Date
Msg-id FKEOIJEHOIKIOEHCGNCLGEMGEDAA.jer@highboard.com
Whole thread Raw
In response to Re: Inserting NULL into Integer column  ("scott.marlowe" <scott.marlowe@ihs.com>)
Responses Re: Inserting NULL into Integer column
List pgsql-sql

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!

Jeremy



pgsql-sql by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Inserting NULL into Integer column
Next
From: "scott.marlowe"
Date:
Subject: Re: Inserting NULL into Integer column