| @@ -60,48 +60,29 @@ | ||
| 60 | 60 | * |
| 61 | 61 | * @param mixed $from |
| 62 | 62 | * @param mixed $filter |
| 63 | 63 | */ |
| 64 | - protected function buildQuery($from, $filter) | |
| 65 | - { | |
| 66 | - | |
| 64 | + protected function buildQuery($from, $filter) { | |
| 67 | 65 | $query = $this->query; |
| 68 | - | |
| 69 | - $sql = array | |
| 70 | - ( | |
| 71 | - 'columns' => null, | |
| 72 | - 'from' => null, | |
| 73 | - 'filter' => null, | |
| 74 | - 'orderBy' => null, | |
| 75 | - 'limits' => null | |
| 76 | - ); | |
| 77 | - | |
| 78 | - $sql[ 'columns' ] = implode( ', ', $query->columns ); | |
| 79 | - | |
| 66 | + $sql = array('columns' => null, 'from' => null,'filter' => null,'orderBy' => null,'limits' => null); | |
| 67 | + // Columns. | |
| 68 | + $sql['columns'] = implode(',', $query->columns); | |
| 80 | 69 | // From. |
| 81 | - $sql[ 'from' ] = " FROM {$from}"; | |
| 82 | - | |
| 70 | + $sql['from'] = " FROM {$from}"; | |
| 83 | 71 | // Where clause. |
| 84 | - if ( ! empty( $filter ) ) | |
| 85 | - { | |
| 86 | - $sql[ 'filter' ] = " WHERE {$filter}"; | |
| 72 | + if (!empty($filter)) { | |
| 73 | + $sql['filter'] = " WHERE {$filter}"; | |
| 87 | 74 | } |
| 88 | - | |
| 89 | 75 | // Order By. |
| 90 | - if ( ! empty( $query->orderBy ) ) | |
| 91 | - { | |
| 92 | - $sql[ 'orderBy' ] = ' ORDER BY ' . implode( ',', $order ); | |
| 76 | + if (!empty($query->orderBy)) { | |
| 77 | + $sql['orderBy'] = ' ORDER BY ' . implode(',', $order); | |
| 93 | 78 | } |
| 94 | - | |
| 95 | 79 | // Limits. |
| 96 | - if ( ! empty( $query->limits ) ) | |
| 97 | - { | |
| 98 | - $sql[ 'limits' ] = " LIMIT {$limits[0]}" . ( isset( $limits[ 1 ] ) ? ",{$limits}" : '' ); | |
| 80 | + if (!empty($query->limits)) { | |
| 81 | + $sql['limits'] = " LIMIT {$limits[0]}" . (isset($limits[1]) ? ",{$limits}" : ''); | |
| 99 | 82 | } |
| 100 | - | |
| 101 | - // Buile query | |
| 102 | - $sql = "SELECT {$sql['columns']}\n\n{$sql['from']}\n\n{$sql['filter']}{$sql['orderBy']}{$sql['limits']};"; | |
| 103 | - | |
| 83 | + // Combine all into one statment. | |
| 84 | + $sql = "SELECT {$sql['columns']}{$sql['from']}{$sql['filter']}{$sql['orderBy']}{$sql['limits']};"; | |
| 104 | 85 | return $sql; |
| 105 | 86 | } |
| 106 | 87 | |
| 107 | 88 | /** |