@@ -25,8 +25,12 @@ discard block |
||
| 25 | 25 | list($columns, $order) = explode(' ', $options['order']); |
| 26 | 26 | usort($filteredArray, $this->getOrderFunction($order, $columns)); |
| 27 | 27 | } |
| 28 | - if (isset($options['offset'])) $filteredArray = array_slice($filteredArray, $options['offset']); |
|
| 29 | - if (isset($options['limit'])) $filteredArray = array_slice($filteredArray, 0, $options['limit']); |
|
| 28 | + if (isset($options['offset'])) { |
|
| 29 | + $filteredArray = array_slice($filteredArray, $options['offset']); |
|
| 30 | + } |
|
| 31 | + if (isset($options['limit'])) { |
|
| 32 | + $filteredArray = array_slice($filteredArray, 0, $options['limit']); |
|
| 33 | + } |
|
| 30 | 34 | return $filteredArray; |
| 31 | 35 | } |
| 32 | 36 | |
@@ -40,23 +44,28 @@ discard block |
||
| 40 | 44 | |
| 41 | 45 | public function deleteByField(array $fields, array $options) { |
| 42 | 46 | foreach ($this->findByField($fields, $options) as $val) { |
| 43 | - if (count($this->id) > 1) $id = $this->getMultiPkSaveId($val); |
|
| 44 | - else $id = $val->{$this->id[0]}; |
|
| 47 | + if (count($this->id) > 1) { |
|
| 48 | + $id = $this->getMultiPkSaveId($val); |
|
| 49 | + } else { |
|
| 50 | + $id = $val->{$this->id[0]}; |
|
| 51 | + } |
|
| 45 | 52 | |
| 46 | 53 | unset($this->data[$id]); |
| 47 | 54 | } |
| 48 | 55 | } |
| 49 | 56 | |
| 50 | 57 | public function save($data) { |
| 51 | - if (count($this->id) > 1) return $this->saveMultiPk($data); |
|
| 52 | - else return $this->saveSinglePk($data); |
|
| 58 | + if (count($this->id) > 1) { |
|
| 59 | + return $this->saveMultiPk($data); |
|
| 60 | + } else { |
|
| 61 | + return $this->saveSinglePk($data); |
|
| 62 | + } |
|
| 53 | 63 | } |
| 54 | 64 | |
| 55 | 65 | private function saveSinglePk($data) { |
| 56 | 66 | if (isset($data->{$this->id[0]})) { |
| 57 | 67 | $id = $data->{$this->id[0]}; |
| 58 | - } |
|
| 59 | - else { |
|
| 68 | + } else { |
|
| 60 | 69 | $id = count($this->data); |
| 61 | 70 | $data->{$this->id[0]} = $id; |
| 62 | 71 | } |
@@ -90,12 +99,16 @@ discard block |
||
| 90 | 99 | if ($aColumn === $bColumn) { |
| 91 | 100 | $sortVal = 0; |
| 92 | 101 | continue; |
| 102 | + } else { |
|
| 103 | + $sortVal = ($aColumn < $bColumn) ? -1 : 1; |
|
| 93 | 104 | } |
| 94 | - else $sortVal = ($aColumn < $bColumn) ? -1 : 1; |
|
| 95 | 105 | break; |
| 96 | 106 | } |
| 97 | - if ($order === 'desc') return -$sortVal; |
|
| 98 | - else return $sortVal; |
|
| 107 | + if ($order === 'desc') { |
|
| 108 | + return -$sortVal; |
|
| 109 | + } else { |
|
| 110 | + return $sortVal; |
|
| 111 | + } |
|
| 99 | 112 | }; |
| 100 | 113 | } |
| 101 | 114 | } |