Fix #4892 - update_batch()
Regression caused by 0c23e9122666a30797079bea9415da135d4f7e12 trying to fix #4871
Supersedes #4929
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index dfd87f9..51916fc 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -550,13 +550,13 @@
$ids = array();
foreach ($values as $key => $val)
{
- $ids[] = $val[$index];
+ $ids[] = $val[$index]['value'];
foreach (array_keys($val) as $field)
{
if ($field !== $index)
{
- $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field];
+ $final[$val[$field]['field']][] = 'WHEN '.$val[$index]['value'].' THEN '.$val[$field]['value'];
}
}
}
@@ -564,12 +564,12 @@
$cases = '';
foreach ($final as $k => $v)
{
- $cases .= $k.' = (CASE '.$index."\n"
+ $cases .= $k.' = (CASE '.$val[$index]['field']."\n"
.implode("\n", $v)."\n"
.'ELSE '.$k.' END), ';
}
- $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
+ $this->where($val[$index]['field'].' IN('.implode(',', $ids).')', NULL, FALSE);
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
}