DB and NULL values

From: Date: Tue, 22 Oct 2002 13:25:40 +0000
Subject: DB and NULL values
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-2530@lists.php.net to get a copy of this message
I'm using Postgresql 7.1 and PEAR/DB I have been having some problems using $db->prepare and $db->execute agains NULL values. I'm posting a very simplified insert into a table but here goes: How do I insert NULL values into the table test_table: create table test_table ( id char(10), valid boolean, primary key (id) ); $sql = $db->prepare("insert into test_table values (?,?)"); $values = ("abc","NULL"); $result = $db->execute($sql,$values); $sql = $db->prepare("insert into test_table values (?,?)"); $values = ("abc",""); $result = $db->execute($sql,$values); Here $result is a DB_Error because 'NULL' isnt a boolean value. How do I set it to NULL without having to writing my sql in full such as insert into test_table values ('abc',NULL); ? I have another question about NULL values and selects. How do I distinguish NULL values and the empty string '' in a result set ? $sql = "select * from test_table"; $result = $db->getRow($sql); Hoping to get some answers. Thanks Birgir Stefansson

« previous php.pear.general (#2530) next »