Sean Chittenden wrote:
> A boolean value is returned as the strings 't' and 'f', not the
> constants true and false. This presents all kinds of interesting
> oddities for code that does something like:
[...]
You're probably already aware of this, but you can use a bit(1) field as a
boolean and this will map to PHP values that will allow you to check for
truth in conditionals. Personally I do that instead of using Postgres's
boolean since other database systems I've worked with don't have a boolean
type, but they all have a bit type. Although I agree that it would be nice
for PHP to map pg's boolean to PHP's boolean...
> The same problem lies with the NULL value, which IMHO, should be
> mapped to the constant NULL, not the string 'NULL'.
I was unable to reproduce this. The following code:
$r = pg_query($dbh, "create table test (field1 varchar(10))");
$r = pg_query($dbh, "insert into test values (NULL)");
$r = pg_query($dbh, "select field1 from test");
$row = pg_fetch_row($r);
var_dump($row);
$r = pg_query($dbh, "drop table test");
outputs:
array(1) {
[0]=>
NULL
}
On PHP 4.3.9, Postgresql 7.4.5, running on Linux (Debian Sarge). If you get
different results perhaps you've uncovered a bug that should be reported...
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php