@@ -126,12 +126,14 @@ discard block |
||
126 | 126 | if (!is_array($order)) { |
127 | 127 | $this->order[] = "{$order} {$type}"; |
128 | 128 | } else { |
129 | - foreach ($order as $item) |
|
130 | - if (!is_array($item)) { |
|
129 | + foreach ($order as $item) { |
|
130 | + if (!is_array($item)) { |
|
131 | 131 | call_user_func_array(array($this, 'order'), $order); |
132 | + } |
|
132 | 133 | break; |
133 | - } else |
|
134 | - $this->order($item); |
|
134 | + } else { |
|
135 | + $this->order($item); |
|
136 | + } |
|
135 | 137 | } |
136 | 138 | } |
137 | 139 | |
@@ -140,8 +142,9 @@ discard block |
||
140 | 142 | $start = intval($start); |
141 | 143 | $len = intval($len); |
142 | 144 | $this->limit = "LIMIT {$start}"; |
143 | - if ($len !== 0) |
|
144 | - $this->limit .= ",{$len}"; |
|
145 | + if ($len !== 0) { |
|
146 | + $this->limit .= ",{$len}"; |
|
147 | + } |
|
145 | 148 | } |
146 | 149 | |
147 | 150 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') |
@@ -154,10 +157,12 @@ discard block |
||
154 | 157 | } |
155 | 158 | } else { |
156 | 159 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
157 | - if ($alias) |
|
158 | - $join .= " AS `{$alias}`"; |
|
159 | - if ($where) |
|
160 | - $join .= " ON {$where}"; |
|
160 | + if ($alias) { |
|
161 | + $join .= " AS `{$alias}`"; |
|
162 | + } |
|
163 | + if ($where) { |
|
164 | + $join .= " ON {$where}"; |
|
165 | + } |
|
161 | 166 | } |
162 | 167 | return $join; |
163 | 168 | } |
@@ -177,13 +182,15 @@ discard block |
||
177 | 182 | $operation = '='; |
178 | 183 | } |
179 | 184 | |
180 | - if ($concatenation === false) |
|
181 | - $concatenation = 'AND'; |
|
182 | - elseif ($concatenation === true) |
|
183 | - $concatenation = ''; |
|
185 | + if ($concatenation === false) { |
|
186 | + $concatenation = 'AND'; |
|
187 | + } elseif ($concatenation === true) { |
|
188 | + $concatenation = ''; |
|
189 | + } |
|
184 | 190 | |
185 | - if ($this->whereString == NULL) |
|
186 | - $this->whereString = ' WHERE '; |
|
191 | + if ($this->whereString == NULL) { |
|
192 | + $this->whereString = ' WHERE '; |
|
193 | + } |
|
187 | 194 | |
188 | 195 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
189 | 196 | if (is_array($value)) { |
@@ -209,12 +216,12 @@ discard block |
||
209 | 216 | $value = "?"; |
210 | 217 | } |
211 | 218 | |
212 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
213 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
214 | - else |
|
215 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
216 | - } |
|
217 | - else { |
|
219 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
220 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
221 | + } else { |
|
222 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
223 | + } |
|
224 | + } else { |
|
218 | 225 | $i = -1; |
219 | 226 | while (isset($where[++$i])) { |
220 | 227 | $item = $where[$i]; |
@@ -229,28 +236,32 @@ discard block |
||
229 | 236 | $this->whereString .= "{$concatenation} "; |
230 | 237 | } |
231 | 238 | |
232 | - if ($this->whereString != NULL) |
|
233 | - $this->whereString .= '('; |
|
234 | - else |
|
235 | - $this->whereString = 'WHERE ('; |
|
239 | + if ($this->whereString != NULL) { |
|
240 | + $this->whereString .= '('; |
|
241 | + } else { |
|
242 | + $this->whereString = 'WHERE ('; |
|
243 | + } |
|
236 | 244 | } |
237 | 245 | |
238 | 246 | if (!is_array($item)) { |
239 | 247 | call_user_func_array(array($this, 'buildWhere'), $where); |
240 | 248 | break; |
241 | 249 | } else { |
242 | - if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') |
|
243 | - if (!isset($item[3])) |
|
250 | + if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') { |
|
251 | + if (!isset($item[3])) |
|
244 | 252 | $concatenation = 'AND'; |
245 | - else |
|
246 | - $concatenation = $item[3]; |
|
247 | - elseif (substr($this->whereString, -1, 1) != '(') |
|
248 | - $this->whereString = 'WHERE '; |
|
253 | + } else { |
|
254 | + $concatenation = $item[3]; |
|
255 | + } |
|
256 | + elseif (substr($this->whereString, -1, 1) != '(') { |
|
257 | + $this->whereString = 'WHERE '; |
|
258 | + } |
|
249 | 259 | |
250 | 260 | $this->buildWhere($item); |
251 | 261 | } |
252 | - if (!isset($where[$i + 1]) && isset($where[$i - 1])) |
|
253 | - $this->whereString .= ') '; |
|
262 | + if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
|
263 | + $this->whereString .= ') '; |
|
264 | + } |
|
254 | 265 | } |
255 | 266 | } |
256 | 267 | } |