@@ 1903-1930 (lines=28) @@ | ||
1900 | * @param string $index WHERE key |
|
1901 | * @return string |
|
1902 | */ |
|
1903 | protected function _update_batch($table, $values, $index) |
|
1904 | { |
|
1905 | $ids = array(); |
|
1906 | foreach ($values as $key => $val) |
|
1907 | { |
|
1908 | $ids[] = $val[$index]; |
|
1909 | ||
1910 | foreach (array_keys($val) as $field) |
|
1911 | { |
|
1912 | if ($field !== $index) |
|
1913 | { |
|
1914 | $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; |
|
1915 | } |
|
1916 | } |
|
1917 | } |
|
1918 | ||
1919 | $cases = ''; |
|
1920 | foreach ($final as $k => $v) |
|
1921 | { |
|
1922 | $cases .= $k." = CASE \n" |
|
1923 | .implode("\n", $v)."\n" |
|
1924 | .'ELSE '.$k.' END, '; |
|
1925 | } |
|
1926 | ||
1927 | $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); |
|
1928 | ||
1929 | return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); |
|
1930 | } |
|
1931 | ||
1932 | // -------------------------------------------------------------------- |
|
1933 |
@@ 183-210 (lines=28) @@ | ||
180 | * @param string $index WHERE key |
|
181 | * @return string |
|
182 | */ |
|
183 | protected function _update_batch($table, $values, $index) |
|
184 | { |
|
185 | $ids = array(); |
|
186 | foreach ($values as $key => $val) |
|
187 | { |
|
188 | $ids[] = $val[$index]; |
|
189 | ||
190 | foreach (array_keys($val) as $field) |
|
191 | { |
|
192 | if ($field !== $index) |
|
193 | { |
|
194 | $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; |
|
195 | } |
|
196 | } |
|
197 | } |
|
198 | ||
199 | $cases = ''; |
|
200 | foreach ($final as $k => $v) |
|
201 | { |
|
202 | $cases .= $k." = CASE \n" |
|
203 | .implode("\n", $v)."\n" |
|
204 | .'ELSE '.$k.' END), '; |
|
205 | } |
|
206 | ||
207 | $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); |
|
208 | ||
209 | return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); |
|
210 | } |
|
211 | ||
212 | // -------------------------------------------------------------------- |
|
213 |
@@ 324-351 (lines=28) @@ | ||
321 | * @param string $index WHERE key |
|
322 | * @return string |
|
323 | */ |
|
324 | protected function _update_batch($table, $values, $index) |
|
325 | { |
|
326 | $ids = array(); |
|
327 | foreach ($values as $key => $val) |
|
328 | { |
|
329 | $ids[] = $val[$index]; |
|
330 | ||
331 | foreach (array_keys($val) as $field) |
|
332 | { |
|
333 | if ($field !== $index) |
|
334 | { |
|
335 | $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; |
|
336 | } |
|
337 | } |
|
338 | } |
|
339 | ||
340 | $cases = ''; |
|
341 | foreach ($final as $k => $v) |
|
342 | { |
|
343 | $cases .= $k.' = (CASE '.$index."\n" |
|
344 | .implode("\n", $v)."\n" |
|
345 | .'ELSE '.$k.' END), '; |
|
346 | } |
|
347 | ||
348 | $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); |
|
349 | ||
350 | return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); |
|
351 | } |
|
352 | ||
353 | // -------------------------------------------------------------------- |
|
354 |
@@ 548-575 (lines=28) @@ | ||
545 | * @param string $index WHERE key |
|
546 | * @return string |
|
547 | */ |
|
548 | protected function _update_batch($table, $values, $index) |
|
549 | { |
|
550 | $ids = array(); |
|
551 | foreach ($values as $key => $val) |
|
552 | { |
|
553 | $ids[] = $val[$index]; |
|
554 | ||
555 | foreach (array_keys($val) as $field) |
|
556 | { |
|
557 | if ($field !== $index) |
|
558 | { |
|
559 | $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; |
|
560 | } |
|
561 | } |
|
562 | } |
|
563 | ||
564 | $cases = ''; |
|
565 | foreach ($final as $k => $v) |
|
566 | { |
|
567 | $cases .= $k.' = (CASE '.$index."\n" |
|
568 | .implode("\n", $v)."\n" |
|
569 | .'ELSE '.$k.' END), '; |
|
570 | } |
|
571 | ||
572 | $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE); |
|
573 | ||
574 | return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where'); |
|
575 | } |
|
576 | ||
577 | // -------------------------------------------------------------------- |
|
578 |