@@ -30,7 +30,7 @@ |
||
30 | 30 | * |
31 | 31 | * Represents a connection to SQL database server |
32 | 32 | */ |
33 | - class Server extends Datasource |
|
33 | + class Server extends Datasource |
|
34 | 34 | { |
35 | 35 | |
36 | 36 | /** |
@@ -168,8 +168,8 @@ |
||
168 | 168 | */ |
169 | 169 | public function rename($newName) |
170 | 170 | { |
171 | - $result = $this->database->renameTable($this->name, $newName); |
|
172 | - if ($result){ |
|
171 | + $result = $this->database->renameTable($this->name, $newName); |
|
172 | + if ($result){ |
|
173 | 173 | $this->name = $newName; |
174 | 174 | } |
175 | 175 | return $result; |
@@ -63,7 +63,7 @@ |
||
63 | 63 | */ |
64 | 64 | protected function getArgName($column) |
65 | 65 | { |
66 | - return '_' . str_replace('.', '_', $column); |
|
66 | + return '_' . str_replace('.', '_', $column); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function column() |
111 | 111 | { |
112 | - $this->columns[] = func_get_args(); |
|
113 | - return $this; |
|
112 | + $this->columns[] = func_get_args(); |
|
113 | + return $this; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function fk($fkName, $srcColumn, $refTable, $refColumn, $onUpdate = 'CASCADE', $onDelete = 'RESTRICT') |
130 | 130 | { |
131 | - $this->foreignKeys[] = array( |
|
131 | + $this->foreignKeys[] = array( |
|
132 | 132 | 'name' => $fkName, |
133 | 133 | 'src_column' => $srcColumn, |
134 | 134 | 'ref_table' => $refTable, |
135 | 135 | 'ref_column' => $refColumn, |
136 | 136 | 'on_update' => $onUpdate, |
137 | 137 | 'on_delete' => $onDelete |
138 | - ); |
|
139 | - return $this; |
|
138 | + ); |
|
139 | + return $this; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | // PK ?, UNIQUE ?, NULL? (PK cannot be null), DEFAULT? |
240 | 240 | // AI is handle with sqltype |
241 | 241 | $result[] = trim(implode(' ', [$sqlName, |
242 | - $sqlType, |
|
243 | - $isPk ? 'NOT NULL' : $sqlConstraintNullable, |
|
244 | - $isPk ? 'PRIMARY KEY' : '', |
|
245 | - $sqlConstraintUnique, |
|
246 | - $sqlDefault])); |
|
242 | + $sqlType, |
|
243 | + $isPk ? 'NOT NULL' : $sqlConstraintNullable, |
|
244 | + $isPk ? 'PRIMARY KEY' : '', |
|
245 | + $sqlConstraintUnique, |
|
246 | + $sqlDefault])); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | // FK CONSTRANT |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function escape($str) |
111 | 111 | { |
112 | - return $this->driver->escape($str); |
|
112 | + return $this->driver->escape($str); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function prepare() |
188 | 188 | { |
189 | - try { |
|
189 | + try { |
|
190 | 190 | // prepare is in a try catch block because sqlite for example could raise |
191 | 191 | // an exception when prepareing the statement (with invalid table name for example) |
192 | 192 | // when mysql and postres wont. |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | try { |
252 | 252 | // prepare bind execute |
253 | 253 | if (!isset($this->pdoStatement)){ |
254 | - if (!$this->prepare()){ |
|
255 | - return false; |
|
256 | - } |
|
254 | + if (!$this->prepare()){ |
|
255 | + return false; |
|
256 | + } |
|
257 | 257 | } |
258 | 258 | $this->bindValues(); |
259 | 259 | return $this->pdoStatement ? $this->pdoStatement->execute() : false; |
@@ -90,12 +90,12 @@ |
||
90 | 90 | */ |
91 | 91 | public function sql() |
92 | 92 | { |
93 | - // Build sql where and escape table name |
|
94 | - $sqlWhere = (isset($this->where)) ? $this->where->sql() : ''; |
|
95 | - $sqlTableName = $this->escape($this->tableName); |
|
93 | + // Build sql where and escape table name |
|
94 | + $sqlWhere = (isset($this->where)) ? $this->where->sql() : ''; |
|
95 | + $sqlTableName = $this->escape($this->tableName); |
|
96 | 96 | |
97 | - // DELETE query |
|
98 | - return trim(sprintf('DELETE FROM %s %s', |
|
97 | + // DELETE query |
|
98 | + return trim(sprintf('DELETE FROM %s %s', |
|
99 | 99 | $sqlTableName, |
100 | 100 | $sqlWhere)); |
101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | case 'sub_query': |
106 | 106 | $colsList[] = '('. $val['query']->sql() .') AS '. $this->escape($val['alias']); |
107 | 107 | break; |
108 | - } |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | return $sqlDistinct . implode(', ', $colsList); |
111 | 111 | } |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | return trim(implode(' ', ['SELECT', |
156 | - $this->sqlColumns(), |
|
157 | - $sqlFromTable, |
|
158 | - $sqlJoins, |
|
159 | - $sqlWhere, |
|
160 | - $sqlGroupBy, |
|
161 | - $sqlHaving, |
|
162 | - $sqlOrderBy, |
|
163 | - $sqlLimit, |
|
164 | - $sqlOffset])); |
|
156 | + $this->sqlColumns(), |
|
157 | + $sqlFromTable, |
|
158 | + $sqlJoins, |
|
159 | + $sqlWhere, |
|
160 | + $sqlGroupBy, |
|
161 | + $sqlHaving, |
|
162 | + $sqlOrderBy, |
|
163 | + $sqlLimit, |
|
164 | + $sqlOffset])); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | public function getAll($ouputFormat = 'default') |
176 | 176 | { |
177 | 177 | // execute query |
178 | - $exec = $this->execute(); |
|
178 | + $exec = $this->execute(); |
|
179 | 179 | |
180 | - // format |
|
181 | - $format = ($ouputFormat === 'default') ? $this->driver->defaultOutputFormat() : $ouputFormat; |
|
180 | + // format |
|
181 | + $format = ($ouputFormat === 'default') ? $this->driver->defaultOutputFormat() : $ouputFormat; |
|
182 | 182 | |
183 | 183 | // return output |
184 | 184 | return QueryBuilder::fetchOutput($this, $exec, $format); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @access protected |
105 | 105 | * @var QueryBuilder |
106 | 106 | */ |
107 | - protected $topQuery = null; |
|
107 | + protected $topQuery = null; |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Constructor |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
128 | + /** |
|
129 | 129 | * Parse the columns arguments for the select query |
130 | 130 | * |
131 | 131 | * @access protected |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function count($alias) |
205 | 205 | { |
206 | - $this->columns[] = array( |
|
206 | + $this->columns[] = array( |
|
207 | 207 | 'type' => 'count', |
208 | 208 | 'alias' => $alias |
209 | 209 | ); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function sum($column, $alias) |
222 | 222 | { |
223 | - $this->columns[] = array( |
|
223 | + $this->columns[] = array( |
|
224 | 224 | 'type' => 'sum', |
225 | 225 | 'name' => $column, |
226 | 226 | 'alias' => $alias |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function returnFunction() |
206 | 206 | { |
207 | - return $this->isGroupOpen === true ? $this : $this->query; |
|
207 | + return $this->isGroupOpen === true ? $this : $this->query; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $sql .= ')'; |
263 | 263 | break; |
264 | 264 | |
265 | - case 'NULL': |
|
265 | + case 'NULL': |
|
266 | 266 | case 'NOT_NULL': |
267 | 267 | $sql .= $isSqlNeedOperator ? ' '.$currentOperator.' ' : ''; |
268 | 268 | $sql .= $item['sql']; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | if (is_string($item['value']) && |
280 | 280 | strlen($item['value']) > strlen(Patabase\Constants::COLUMN_LITERALL) && |
281 | 281 | substr($item['value'], 0, strlen(Patabase\Constants::COLUMN_LITERALL)) === |
282 | - Patabase\Constants::COLUMN_LITERALL) { |
|
282 | + Patabase\Constants::COLUMN_LITERALL) { |
|
283 | 283 | |
284 | 284 | $arg = substr($item['value'], strlen(Patabase\Constants::COLUMN_LITERALL)); |
285 | 285 | $sql .= $isSqlNeedOperator ? ' '.$currentOperator.' ' : ''; |