| @@ 291-304 (lines=14) @@ | ||
| 288 | $query .= 'BY '.$this->by.' '; |
|
| 289 | } |
|
| 290 | ||
| 291 | if (!empty($this->order_by)) { |
|
| 292 | $query .= 'ORDER BY '; |
|
| 293 | ||
| 294 | $order_arr = array(); |
|
| 295 | ||
| 296 | foreach ($this->order_by as $order) { |
|
| 297 | $order_sub = $order['column'].' '; |
|
| 298 | $order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC'); |
|
| 299 | ||
| 300 | $order_arr[] = $order_sub; |
|
| 301 | } |
|
| 302 | ||
| 303 | $query .= implode(', ', $order_arr).' '; |
|
| 304 | } |
|
| 305 | ||
| 306 | if ($this->limit !== null || $this->offset !== null) { |
|
| 307 | if ($this->offset === null) { |
|
| @@ 565-581 (lines=17) @@ | ||
| 562 | $query .= 'GROUP BY '.implode(', ', $this->group_by).' '; |
|
| 563 | } |
|
| 564 | ||
| 565 | if (!empty($this->within_group_order_by)) { |
|
| 566 | $query .= 'WITHIN GROUP ORDER BY '; |
|
| 567 | ||
| 568 | $order_arr = array(); |
|
| 569 | ||
| 570 | foreach ($this->within_group_order_by as $order) { |
|
| 571 | $order_sub = $order['column'].' '; |
|
| 572 | ||
| 573 | if ($order['direction'] !== null) { |
|
| 574 | $order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC'); |
|
| 575 | } |
|
| 576 | ||
| 577 | $order_arr[] = $order_sub; |
|
| 578 | } |
|
| 579 | ||
| 580 | $query .= implode(', ', $order_arr).' '; |
|
| 581 | } |
|
| 582 | ||
| 583 | if (!empty($this->having)) { |
|
| 584 | $query .= 'HAVING '.$this->compileFilterCondition($this->having); |
|
| @@ 587-603 (lines=17) @@ | ||
| 584 | $query .= 'HAVING '.$this->compileFilterCondition($this->having); |
|
| 585 | } |
|
| 586 | ||
| 587 | if (!empty($this->order_by)) { |
|
| 588 | $query .= 'ORDER BY '; |
|
| 589 | ||
| 590 | $order_arr = array(); |
|
| 591 | ||
| 592 | foreach ($this->order_by as $order) { |
|
| 593 | $order_sub = $order['column'].' '; |
|
| 594 | ||
| 595 | if ($order['direction'] !== null) { |
|
| 596 | $order_sub .= ((strtolower($order['direction']) === 'desc') ? 'DESC' : 'ASC'); |
|
| 597 | } |
|
| 598 | ||
| 599 | $order_arr[] = $order_sub; |
|
| 600 | } |
|
| 601 | ||
| 602 | $query .= implode(', ', $order_arr).' '; |
|
| 603 | } |
|
| 604 | ||
| 605 | if ($this->limit !== null || $this->offset !== null) { |
|
| 606 | if ($this->offset === null) { |
|