Checking for null values before converting to boolean

This commit is contained in:
José Lorenzo Rodríguez 2011-01-04 17:00:10 -04:30
parent de6eda964e
commit 665e560310
3 changed files with 3 additions and 3 deletions

View file

@ -238,7 +238,7 @@ class DboMysql extends DboSource {
foreach ($this->map as $col => $meta) { foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta; list($table, $column, $type) = $meta;
$resultRow[$table][$column] = $row[$col]; $resultRow[$table][$column] = $row[$col];
if ($type == 'boolean') { if ($type == 'boolean' && !is_null($row[$col])) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
} }
} }

View file

@ -707,7 +707,7 @@ class DboPostgres extends DboSource {
switch ($type) { switch ($type) {
case 'bool': case 'bool':
$resultRow[$table][$column] = $this->boolean($row[$index]); $resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
break; break;
case 'binary': case 'binary':
case 'bytea': case 'bytea':

View file

@ -336,7 +336,7 @@ class DboSqlite extends DboSource {
foreach ($this->map as $col => $meta) { foreach ($this->map as $col => $meta) {
list($table, $column, $tpye) = $meta; list($table, $column, $tpye) = $meta;
$resultRow[$table][$column] = $row[$col]; $resultRow[$table][$column] = $row[$col];
if ($type === 'boolean') { if ($type == 'boolean' && !is_null($row[$col])) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
} }
} }