db2 driver updates

This commit is contained in:
Mark Gregory
2026-11-11 10:04:00 +00:00
parent 6a7f58cb98
commit 2e51121c5b
2 changed files with 166 additions and 78 deletions
+33 -14
View File
@@ -25,28 +25,47 @@ class Db2Connection extends Connection
$fetchUsing
);
foreach ($rows as $row) {
if (! is_object($row)) {
foreach ($rows as &$row) {
if (! is_object($row) && ! is_array($row)) {
continue;
}
foreach ($row as $key => $value) {
if ($value === Db2QueryGrammar::NULL_TIMESTAMP_SENTINEL) {
$row->{$key} = null;
$values = (array) $row;
$result = [];
$previousColumn = null;
foreach ($values as $key => $value) {
if (
is_string($key) &&
preg_match('/^__db2_null_flag_[0-9]+$/i', $key)
) {
if ($previousColumn === null) {
throw new \RuntimeException(
'Db2 NULL indicator has no preceding column.'
);
}
if ((string) $value === '1') {
$result[$previousColumn] = null;
} elseif ((string) $value !== '0') {
throw new \RuntimeException(
'Unexpected Db2 NULL indicator value.'
);
}
$previousColumn = null;
continue;
}
if (
in_array($key, [
'two_factor_secret',
'two_factor_recovery_codes',
], true)
&& $value === Db2QueryGrammar::NULL_STRING_SENTINEL
) {
$row->{$key} = null;
}
$result[$key] = $value;
$previousColumn = $key;
}
$row = is_object($row)
? (object) $result
: $result;
}
unset($row);
return $rows;
}