-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
- Loading branch information
There are no files selected for viewing
2 comments
on commit d06acd8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based upon the update_batch method described above, I modified it slightly since in my case it not worked. After that, it worked.
So, this method I put on the system/database/drivers/postgre/postgre_driver.php:
// --------------------------------------------------------------------
/**
* Update_Batch statement
*
* Generates a platform-specific batch update string from the supplied data
*
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
protected function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
foreach ($values as $key => $val)
{
$ids[] = $val[$index];
foreach (array_keys($val) as $field)
{
if ($field != $index)
{
$final[$field][] = 'WHEN '. $index . ' = ' .$val[$index].' THEN '.$val[$field];
}
}
}
$cases = '';
foreach ($final as $k => $v)
{
$cases .= $k .' = (CASE '. "\n"
.implode("\n", $v)."\n"
.'ELSE '.$k.' END), ';
}
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2)
.' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '')
.$index.' IN ('.implode(',', $ids).')';
}
Until now, I have not needed to update the other two files.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really old commit, the current version of this code looks a lot more different. You should be updating to the latest CI version, not patching stock files by hand.
Also, comments on commits are really unfriendly - hard to find and easy to lose track of, and just pasting an entire function only makes it worse ... One has to spend minutes searching for the tiny differences (on 3 lines out of 28 here, and only 2 are relevant); a diff is way, way better.
The second variable $k should be $index, otherwise it will filter down the index on a wrong column.