Conditions | 3 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
4 | protected function reorderItems($list, array $values, array $order) { |
||
5 | $pool = array_values($values); |
||
6 | sort($pool); |
||
7 | |||
8 | foreach(array_values($order) as $pos => $id) { |
||
9 | if($values[$id] != $pool[$pos]) { |
||
10 | DB::query(sprintf( |
||
11 | 'UPDATE "%s" SET "%s" = %d WHERE %s', |
||
12 | $this->getSortTable($list), |
||
13 | $this->getSortField(), |
||
14 | $pool[$pos], |
||
15 | $this->getSortTableClauseForIds($list, $id) |
||
16 | )); |
||
17 | DB::query(sprintf( |
||
18 | 'UPDATE "%s_Live" SET "%s" = %d WHERE %s', |
||
19 | $this->getSortTable($list), |
||
20 | $this->getSortField(), |
||
21 | $pool[$pos], |
||
22 | $this->getSortTableClauseForIds($list, $id) |
||
23 | )); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | $this->extend('onAfterReorderItems', $list); |
||
28 | } |
||
29 | } |