summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/postgre/postgre_driver.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-05-25 02:03:04 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-05-25 02:03:04 +0200
commit64ccbd75b6725abc4770e0911a2af0f8d5bf7e6d (patch)
treeaab3d8c90b9d8ec858ad457d54c96e3b59e3a69b /system/database/drivers/postgre/postgre_driver.php
parent502942bd94fef292970df331b15652ef6e1385e7 (diff)
parentf33e2ff30b0a9c54d6e8adbe88662838b9bd525e (diff)
Explicitely testing escape_like_str API
Diffstat (limited to 'system/database/drivers/postgre/postgre_driver.php')
-rw-r--r--system/database/drivers/postgre/postgre_driver.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 0ddfd0abe..30689cc70 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -539,6 +539,47 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * 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 '.$val[$index].' THEN '.$val[$field];
+ }
+ }
+ }
+
+ $cases = '';
+ foreach ($final as $k => $v)
+ {
+ $cases .= $k.' = (CASE '.$k."\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).')';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Delete statement
*
* Generates a platform-specific delete string from the supplied data