I have a boolean column in a PostgreSQL table. In pgAdmin III, the table view shows 'TRUE' and 'FALSE' for the column. When I do a SQL 'select *', that other window shows 't' and 'f'. Is this some configuration problem? Shouldn't it also show 'TRUE' and 'FALSE'?
Then we come to PHP. I have the following code to deal with this boolean (actually I'm doing something different, but simplified it here):
$q = "select * from tax where id = $1";
$res = pg_query_params($conn,$q,[$id]);
if ($res) {
$row = pg_fetch_array($res,NULL,PGSQL_ASSOC);
$valido = $row['valido'];
echo $valido; // prints 'f' (== 'FALSE' on database)
if ($valido) {
echo 'valid'; // gets here
} else {
echo 'invalid';
}
}
The database says 'FALSE', php reads 'f' and treat it as 'TRUE'. Is this some faulty configuration, or php always reads a boolean value as a text interpreted as the opposite of the original value?