@@ -36,7 +36,6 @@ |
||
36 | 36 | * Class QueryException |
37 | 37 | * @package Platine\Database\Exception |
38 | 38 | */ |
39 | -class QueryException extends ConnectionException |
|
40 | -{ |
|
39 | +class QueryException extends ConnectionException { |
|
41 | 40 | |
42 | 41 | } |
@@ -36,7 +36,6 @@ |
||
36 | 36 | * Class ConnectionException |
37 | 37 | * @package Platine\Database\Exception |
38 | 38 | */ |
39 | -class ConnectionException extends \Exception |
|
40 | -{ |
|
39 | +class ConnectionException extends \Exception { |
|
41 | 40 | |
42 | 41 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class HavingStatement |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class HavingStatement |
|
54 | -{ |
|
53 | +class HavingStatement { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The Query statement instance |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | * HavingStatement constructor. |
70 | 69 | * @param QueryStatement|null $queryStatement |
71 | 70 | */ |
72 | - public function __construct(QueryStatement $queryStatement = null) |
|
73 | - { |
|
71 | + public function __construct(QueryStatement $queryStatement = null) { |
|
74 | 72 | if ($queryStatement === null) { |
75 | 73 | $queryStatement = new QueryStatement(); |
76 | 74 | } |
@@ -108,8 +106,7 @@ discard block |
||
108 | 106 | /** |
109 | 107 | * @inheritDoc |
110 | 108 | */ |
111 | - public function __clone() |
|
112 | - { |
|
109 | + public function __clone() { |
|
113 | 110 | $this->queryStatement = clone $this->queryStatement; |
114 | 111 | $this->expression = new HavingExpression($this->queryStatement); |
115 | 112 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class BaseStatement |
53 | 53 | * @package Platine\Database\Query |
54 | 54 | */ |
55 | -class BaseStatement extends WhereStatement |
|
56 | -{ |
|
55 | +class BaseStatement extends WhereStatement { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * @param string|string[] $table |
@@ -61,8 +60,7 @@ discard block |
||
61 | 60 | * |
62 | 61 | * @return Delete|Select|BaseStatement |
63 | 62 | */ |
64 | - public function join($table, Closure $closure) |
|
65 | - { |
|
63 | + public function join($table, Closure $closure) { |
|
66 | 64 | $this->queryStatement->addJoinClause('INNER', $table, $closure); |
67 | 65 | |
68 | 66 | return $this; |
@@ -74,8 +72,7 @@ discard block |
||
74 | 72 | * |
75 | 73 | * @return Delete|Select|BaseStatement |
76 | 74 | */ |
77 | - public function leftJoin($table, Closure $closure) |
|
78 | - { |
|
75 | + public function leftJoin($table, Closure $closure) { |
|
79 | 76 | $this->queryStatement->addJoinClause('LEFT', $table, $closure); |
80 | 77 | |
81 | 78 | return $this; |
@@ -87,8 +84,7 @@ discard block |
||
87 | 84 | * |
88 | 85 | * @return Delete|Select|BaseStatement |
89 | 86 | */ |
90 | - public function rightJoin($table, Closure $closure) |
|
91 | - { |
|
87 | + public function rightJoin($table, Closure $closure) { |
|
92 | 88 | $this->queryStatement->addJoinClause('RIGHT', $table, $closure); |
93 | 89 | |
94 | 90 | return $this; |
@@ -100,8 +96,7 @@ discard block |
||
100 | 96 | * |
101 | 97 | * @return Delete|Select|BaseStatement |
102 | 98 | */ |
103 | - public function fullJoin($table, Closure $closure) |
|
104 | - { |
|
99 | + public function fullJoin($table, Closure $closure) { |
|
105 | 100 | $this->queryStatement->addJoinClause('FULL', $table, $closure); |
106 | 101 | |
107 | 102 | return $this; |
@@ -113,8 +108,7 @@ discard block |
||
113 | 108 | * |
114 | 109 | * @return Delete|Select|BaseStatement |
115 | 110 | */ |
116 | - public function crossJoin($table, Closure $closure) |
|
117 | - { |
|
111 | + public function crossJoin($table, Closure $closure) { |
|
118 | 112 | $this->queryStatement->addJoinClause('CROSS', $table, $closure); |
119 | 113 | |
120 | 114 | return $this; |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class WhereStatement |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class WhereStatement |
|
54 | -{ |
|
53 | +class WhereStatement { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The Query statement instance |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | * WhereStatement constructor. |
70 | 69 | * @param QueryStatement|null $queryStatement |
71 | 70 | */ |
72 | - public function __construct(QueryStatement $queryStatement = null) |
|
73 | - { |
|
71 | + public function __construct(QueryStatement $queryStatement = null) { |
|
74 | 72 | if ($queryStatement === null) { |
75 | 73 | $queryStatement = new QueryStatement(); |
76 | 74 | } |
@@ -85,8 +83,7 @@ discard block |
||
85 | 83 | * |
86 | 84 | * @return WhereStatement|Where |
87 | 85 | */ |
88 | - protected function addWhereCondition($column, string $separator = 'AND', bool $isExpression = false) |
|
89 | - { |
|
86 | + protected function addWhereCondition($column, string $separator = 'AND', bool $isExpression = false) { |
|
90 | 87 | if (($column instanceof \Closure) && !$isExpression) { |
91 | 88 | $this->queryStatement->addWhereGroup($column, $separator); |
92 | 89 | |
@@ -109,8 +106,7 @@ discard block |
||
109 | 106 | * |
110 | 107 | * @return Where|Select|Delete|Update |
111 | 108 | */ |
112 | - public function where($column, bool $isExpression = false) |
|
113 | - { |
|
109 | + public function where($column, bool $isExpression = false) { |
|
114 | 110 | return $this->addWhereCondition($column, 'AND', $isExpression); |
115 | 111 | } |
116 | 112 | |
@@ -120,8 +116,7 @@ discard block |
||
120 | 116 | * |
121 | 117 | * @return Where|Select|Delete|Update |
122 | 118 | */ |
123 | - public function orWhere($column, bool $isExpression = false) |
|
124 | - { |
|
119 | + public function orWhere($column, bool $isExpression = false) { |
|
125 | 120 | return $this->addWhereCondition($column, 'OR', $isExpression); |
126 | 121 | } |
127 | 122 | |
@@ -164,8 +159,7 @@ discard block |
||
164 | 159 | /** |
165 | 160 | * @inheritDoc |
166 | 161 | */ |
167 | - public function __clone() |
|
168 | - { |
|
162 | + public function __clone() { |
|
169 | 163 | $this->queryStatement = clone $this->queryStatement; |
170 | 164 | $this->where = new Where($this, $this->queryStatement); |
171 | 165 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class ColumnExpression |
53 | 53 | * @package Platine\Database\Query |
54 | 54 | */ |
55 | -class ColumnExpression |
|
56 | -{ |
|
55 | +class ColumnExpression { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * The Query statement instance |
@@ -65,8 +64,7 @@ discard block |
||
65 | 64 | * ColumnExpression constructor. |
66 | 65 | * @param QueryStatement $queryStatement |
67 | 66 | */ |
68 | - public function __construct(QueryStatement $queryStatement) |
|
69 | - { |
|
67 | + public function __construct(QueryStatement $queryStatement) { |
|
70 | 68 | $this->queryStatement = $queryStatement; |
71 | 69 | } |
72 | 70 | |
@@ -160,8 +158,7 @@ discard block |
||
160 | 158 | return $this->column((new Expression())->max($column, $distinct), $alias); |
161 | 159 | } |
162 | 160 | |
163 | - public function __clone() |
|
164 | - { |
|
161 | + public function __clone() { |
|
165 | 162 | $this->queryStatement = clone $this->queryStatement; |
166 | 163 | } |
167 | 164 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class SubQuery |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class SubQuery |
|
54 | -{ |
|
53 | +class SubQuery { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * The Select instance |
@@ -79,8 +78,7 @@ discard block |
||
79 | 78 | /** |
80 | 79 | * @inheritDoc |
81 | 80 | */ |
82 | - public function __clone() |
|
83 | - { |
|
81 | + public function __clone() { |
|
84 | 82 | $this->select = clone $this->select; |
85 | 83 | } |
86 | 84 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class Query |
53 | 53 | * @package Platine\Database\Query |
54 | 54 | */ |
55 | -class Query extends BaseStatement |
|
56 | -{ |
|
55 | +class Query extends BaseStatement { |
|
57 | 56 | |
58 | 57 | /** |
59 | 58 | * @var Connection |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | * @param string|array $tables |
72 | 71 | * @param QueryStatement|null $queryStatement |
73 | 72 | */ |
74 | - public function __construct(Connection $connection, $tables, QueryStatement $queryStatement = null) |
|
75 | - { |
|
73 | + public function __construct(Connection $connection, $tables, QueryStatement $queryStatement = null) { |
|
76 | 74 | parent::__construct($queryStatement); |
77 | 75 | |
78 | 76 | $this->connection = $connection; |
@@ -84,8 +82,7 @@ discard block |
||
84 | 82 | * |
85 | 83 | * @return Select|SelectStatement |
86 | 84 | */ |
87 | - public function distinct(bool $value = true) |
|
88 | - { |
|
85 | + public function distinct(bool $value = true) { |
|
89 | 86 | return $this->buildSelect()->distinct($value); |
90 | 87 | } |
91 | 88 | |
@@ -94,8 +91,7 @@ discard block |
||
94 | 91 | * |
95 | 92 | * @return Select|SelectStatement |
96 | 93 | */ |
97 | - public function groupBy($columns) |
|
98 | - { |
|
94 | + public function groupBy($columns) { |
|
99 | 95 | $this->buildSelect()->groupBy($columns); |
100 | 96 | } |
101 | 97 | |
@@ -104,8 +100,7 @@ discard block |
||
104 | 100 | * |
105 | 101 | * @return Select|SelectStatement |
106 | 102 | */ |
107 | - public function having($column, \Closure $value = null) |
|
108 | - { |
|
103 | + public function having($column, \Closure $value = null) { |
|
109 | 104 | $this->buildSelect()->having($column, $value); |
110 | 105 | } |
111 | 106 | |
@@ -114,8 +109,7 @@ discard block |
||
114 | 109 | * |
115 | 110 | * @return Select|SelectStatement |
116 | 111 | */ |
117 | - public function orHaving($column, \Closure $value = null) |
|
118 | - { |
|
112 | + public function orHaving($column, \Closure $value = null) { |
|
119 | 113 | $this->buildSelect()->orHaving($column, $value); |
120 | 114 | } |
121 | 115 | |
@@ -125,8 +119,7 @@ discard block |
||
125 | 119 | * |
126 | 120 | * @return Select|SelectStatement |
127 | 121 | */ |
128 | - public function orderBy($columns, string $order = 'ASC') |
|
129 | - { |
|
122 | + public function orderBy($columns, string $order = 'ASC') { |
|
130 | 123 | return $this->buildSelect()->orderBy($columns, $order); |
131 | 124 | } |
132 | 125 | |
@@ -135,8 +128,7 @@ discard block |
||
135 | 128 | * |
136 | 129 | * @return Select|SelectStatement |
137 | 130 | */ |
138 | - public function limit(int $value) |
|
139 | - { |
|
131 | + public function limit(int $value) { |
|
140 | 132 | return $this->buildSelect()->limit($value); |
141 | 133 | } |
142 | 134 | |
@@ -145,8 +137,7 @@ discard block |
||
145 | 137 | * |
146 | 138 | * @return Select|SelectStatement |
147 | 139 | */ |
148 | - public function offset(int $value) |
|
149 | - { |
|
140 | + public function offset(int $value) { |
|
150 | 141 | return $this->buildSelect()->offset($value); |
151 | 142 | } |
152 | 143 | |
@@ -155,8 +146,7 @@ discard block |
||
155 | 146 | * @param string|null $database |
156 | 147 | * @return Select|SelectStatement |
157 | 148 | */ |
158 | - public function into(string $table, string $database = null) |
|
159 | - { |
|
149 | + public function into(string $table, string $database = null) { |
|
160 | 150 | return $this->buildSelect()->into($table, $database); |
161 | 151 | } |
162 | 152 | |
@@ -165,8 +155,7 @@ discard block |
||
165 | 155 | * |
166 | 156 | * @return Select|SelectStatement |
167 | 157 | */ |
168 | - public function select($columns = []) |
|
169 | - { |
|
158 | + public function select($columns = []) { |
|
170 | 159 | return $this->buildSelect()->select($columns); |
171 | 160 | } |
172 | 161 | |
@@ -184,8 +173,7 @@ discard block |
||
184 | 173 | * |
185 | 174 | * @return Select|SelectStatement |
186 | 175 | */ |
187 | - public function column($name) |
|
188 | - { |
|
176 | + public function column($name) { |
|
189 | 177 | return $this->buildSelect()->column($name); |
190 | 178 | } |
191 | 179 | |
@@ -206,8 +194,7 @@ discard block |
||
206 | 194 | * |
207 | 195 | * @return int|float |
208 | 196 | */ |
209 | - public function avg($column, bool $distinct = false) |
|
210 | - { |
|
197 | + public function avg($column, bool $distinct = false) { |
|
211 | 198 | return $this->buildSelect()->avg($column, $distinct); |
212 | 199 | } |
213 | 200 | |
@@ -217,8 +204,7 @@ discard block |
||
217 | 204 | * |
218 | 205 | * @return int|float |
219 | 206 | */ |
220 | - public function sum($column, bool $distinct = false) |
|
221 | - { |
|
207 | + public function sum($column, bool $distinct = false) { |
|
222 | 208 | return $this->buildSelect()->sum($column, $distinct); |
223 | 209 | } |
224 | 210 | |
@@ -228,8 +214,7 @@ discard block |
||
228 | 214 | * |
229 | 215 | * @return int|float |
230 | 216 | */ |
231 | - public function min($column, bool $distinct = false) |
|
232 | - { |
|
217 | + public function min($column, bool $distinct = false) { |
|
233 | 218 | return $this->buildSelect()->min($column, $distinct); |
234 | 219 | } |
235 | 220 | |
@@ -239,8 +224,7 @@ discard block |
||
239 | 224 | * |
240 | 225 | * @return int|float |
241 | 226 | */ |
242 | - public function max($column, bool $distinct = false) |
|
243 | - { |
|
227 | + public function max($column, bool $distinct = false) { |
|
244 | 228 | return $this->buildSelect()->max($column, $distinct); |
245 | 229 | } |
246 | 230 |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class SelectStatement |
51 | 51 | * @package Platine\Database\Query |
52 | 52 | */ |
53 | -class SelectStatement extends BaseStatement |
|
54 | -{ |
|
53 | +class SelectStatement extends BaseStatement { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * @var HavingStatement |
@@ -63,8 +62,7 @@ discard block |
||
63 | 62 | * @param string|array $tables |
64 | 63 | * @param QueryStatement|null $queryStatement |
65 | 64 | */ |
66 | - public function __construct($tables, QueryStatement $queryStatement = null) |
|
67 | - { |
|
65 | + public function __construct($tables, QueryStatement $queryStatement = null) { |
|
68 | 66 | parent::__construct($queryStatement); |
69 | 67 | |
70 | 68 | if (!is_array($tables)) { |
@@ -177,8 +175,7 @@ discard block |
||
177 | 175 | /** |
178 | 176 | * @param string|Expression|\Closure|string[]|Expression[]|\Closure[] $columns |
179 | 177 | */ |
180 | - public function select($columns = []) |
|
181 | - { |
|
178 | + public function select($columns = []) { |
|
182 | 179 | $expr = new ColumnExpression($this->queryStatement); |
183 | 180 | |
184 | 181 | if ($columns instanceof \Closure) { |
@@ -194,8 +191,7 @@ discard block |
||
194 | 191 | /** |
195 | 192 | * @param string|Expression|\Closure $name |
196 | 193 | */ |
197 | - public function column($name) |
|
198 | - { |
|
194 | + public function column($name) { |
|
199 | 195 | (new ColumnExpression($this->queryStatement))->column($name); |
200 | 196 | } |
201 | 197 | |
@@ -203,8 +199,7 @@ discard block |
||
203 | 199 | * @param string|Expression|\Closure $column |
204 | 200 | * @param bool $distinct |
205 | 201 | */ |
206 | - public function count($column = '*', bool $distinct = false) |
|
207 | - { |
|
202 | + public function count($column = '*', bool $distinct = false) { |
|
208 | 203 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
209 | 204 | } |
210 | 205 | |
@@ -212,8 +207,7 @@ discard block |
||
212 | 207 | * @param string|Expression|\Closure $column |
213 | 208 | * @param bool $distinct |
214 | 209 | */ |
215 | - public function avg($column, bool $distinct = false) |
|
216 | - { |
|
210 | + public function avg($column, bool $distinct = false) { |
|
217 | 211 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
218 | 212 | } |
219 | 213 | |
@@ -221,8 +215,7 @@ discard block |
||
221 | 215 | * @param string|Expression|\Closure $column |
222 | 216 | * @param bool $distinct |
223 | 217 | */ |
224 | - public function sum($column, bool $distinct = false) |
|
225 | - { |
|
218 | + public function sum($column, bool $distinct = false) { |
|
226 | 219 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
227 | 220 | } |
228 | 221 | |
@@ -230,8 +223,7 @@ discard block |
||
230 | 223 | * @param string|Expression|\Closure $column |
231 | 224 | * @param bool $distinct |
232 | 225 | */ |
233 | - public function min($column, bool $distinct = false) |
|
234 | - { |
|
226 | + public function min($column, bool $distinct = false) { |
|
235 | 227 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
236 | 228 | } |
237 | 229 | |
@@ -239,16 +231,14 @@ discard block |
||
239 | 231 | * @param string|Expression|\Closure $column |
240 | 232 | * @param bool $distinct |
241 | 233 | */ |
242 | - public function max($column, bool $distinct = false) |
|
243 | - { |
|
234 | + public function max($column, bool $distinct = false) { |
|
244 | 235 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
245 | 236 | } |
246 | 237 | |
247 | 238 | /** |
248 | 239 | * @inheritDoc |
249 | 240 | */ |
250 | - public function __clone() |
|
251 | - { |
|
241 | + public function __clone() { |
|
252 | 242 | parent::__clone(); |
253 | 243 | $this->havingStatement = new HavingStatement($this->queryStatement); |
254 | 244 | } |