Re: empty form field => pgsql NULL gracefully how?
| From: | Richard Lynch | Date: | Fri, 16 Feb 2001 00:40:01 +0000 |
| Subject: | Re: empty form field => pgsql NULL gracefully how? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40034@lists.php.net to get a copy of this message | ||
> INSERT INTO testtab2
> VALUES ( upper('$symbol'), '$two_liner', '$href',
> '$full_desc', '$submitter_name',
> '$submitter_email', CURRENT_TIMESTAMP )
>
> I hate to muck them up with a bunch of tests for empty vars, which then
> need to be replaced with NULL and have the single quotes ommited, etc. if
> there is some more graceful way?
$foo = strlen($foo) ? "'$foo'" : 'NULL';
.
.
.
$query = "insert into bar (foo,...) values($foo,...)";
--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm