@@ -28,9 +28,9 @@ |
||
28 | 28 | |
29 | 29 | public function __toString() |
30 | 30 | { |
31 | - return PHP_EOL . 'load: ' |
|
31 | + return PHP_EOL.'load: ' |
|
32 | 32 | . json_encode($this->load) |
33 | - . PHP_EOL . 'alterations: ' |
|
33 | + . PHP_EOL.'alterations: ' |
|
34 | 34 | . json_encode(array_keys($this->alterations)); |
35 | 35 | } |
36 | 36 |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | continue; // dont load the log information |
44 | 44 | } else { |
45 | 45 | $m = []; |
46 | - if (preg_match('/(.+)_(' . $fk_column->foreignColumnName() . ')$/', $fk_column->name(), $m)) { |
|
46 | + if (preg_match('/(.+)_('.$fk_column->foreignColumnName().')$/', $fk_column->name(), $m)) { |
|
47 | 47 | $foreign_table_alias = $m[1]; |
48 | 48 | } else { |
49 | 49 | $foreign_table_alias = $foreign_table_name; |
50 | 50 | } |
51 | - $foreign_table_alias = $single_fk === true ? $foreign_table_alias : $foreign_table_alias . '_' . $fk_column->name(); |
|
51 | + $foreign_table_alias = $single_fk === true ? $foreign_table_alias : $foreign_table_alias.'_'.$fk_column->name(); |
|
52 | 52 | |
53 | 53 | // auto select non nullable columns |
54 | 54 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | public function join($table_names, $joins, $join_type = '') |
71 | 71 | { |
72 | - list($join_table_name,$join_table_alias) = self::processParamTableNames($table_names); |
|
72 | + list($join_table_name, $join_table_alias) = self::processParamTableNames($table_names); |
|
73 | 73 | |
74 | 74 | if (preg_match('/^(INNER|LEFT|RIGHT|FULL)(\sOUTER)?/i', $join_type) !== 1) { |
75 | 75 | $join_type = ''; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | if (is_null($other_table->column("$select_field"))) { |
160 | 160 | $computed_selection = "$select_field"; // table column does not exist, no nood to prefix |
161 | 161 | } else { |
162 | - $computed_selection = "$other_table_alias.$select_field as " . $other_table_alias . "_$select_field"; |
|
162 | + $computed_selection = "$other_table_alias.$select_field as ".$other_table_alias."_$select_field"; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // vd($computed_selection); |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | foreach ($join_fields as $join_cond) { |
180 | 180 | if (isset($join_cond[3])) { // 4 joins param -> t.f = t.f |
181 | 181 | list($table, $field, $join_table, $join_table_field) = $join_cond; |
182 | - $join_parts [] = $this->backTick($field, $table) . ' = ' . $this->backTick($join_table_field, $join_table); |
|
182 | + $join_parts [] = $this->backTick($field, $table).' = '.$this->backTick($join_table_field, $join_table); |
|
183 | 183 | } elseif (isset($join_cond[2])) { // 3 joins param -> t.f = v |
184 | 184 | list($table, $field, $value) = $join_cond; |
185 | - $bind_label = ':loj_' . $join_table_alias . '_' . $table . '_' . $field; |
|
185 | + $bind_label = ':loj_'.$join_table_alias.'_'.$table.'_'.$field; |
|
186 | 186 | $this->addBinding($field, $value, null, $bind_label); |
187 | 187 | |
188 | - $join_parts [] = $this->backTick($field, $table) . ' = ' . $bind_label; |
|
188 | + $join_parts [] = $this->backTick($field, $table).' = '.$bind_label; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | return sprintf('%s JOIN `%s` %s ON %s', $join_type, $join_table_name, $join_table_alias, implode(' AND ', $join_parts)); |
@@ -44,7 +44,7 @@ |
||
44 | 44 | $value = 0; |
45 | 45 | } |
46 | 46 | $binding_names[$field_name] = $this->addBinding($field_name, $value); |
47 | - $this->alterations [] = $this->backTick($field_name) . ' = ' . $binding_names[$field_name]; |
|
47 | + $this->alterations [] = $this->backTick($field_name).' = '.$binding_names[$field_name]; |
|
48 | 48 | } |
49 | 49 | return $binding_names; |
50 | 50 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | public function bindLabel($field, $table_name = null): string |
140 | 140 | { |
141 | - return ':' . $this->tableLabel($table_name) . '_' . $field; |
|
141 | + return ':'.$this->tableLabel($table_name).'_'.$field; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | //------------------------------------------------------------ Run |
@@ -157,8 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($this->prepared_statement->execute($this->getBindings()) !== false) { |
160 | - // execute returns TRUE on success or FALSE on failure. |
|
161 | - ++self::$executions; |
|
160 | + // execute returns TRUE on success or FALSE on failure.++self::$executions; |
|
162 | 161 | |
163 | 162 | $this->isExecuted(true); |
164 | 163 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | throw new CruditesException('INSERT_FIELDS_BINDINGS_MISMATCH'); |
48 | 48 | } |
49 | 49 | |
50 | - $fields = '`' . implode('`, `', $this->query_fields) . '`'; |
|
50 | + $fields = '`'.implode('`, `', $this->query_fields).'`'; |
|
51 | 51 | $values = implode(', ', array_keys($this->bindings)); |
52 | 52 | |
53 | 53 | return sprintf('INSERT INTO `%s` (%s) VALUES (%s)', $this->table, $fields, $values); |
@@ -49,22 +49,22 @@ discard block |
||
49 | 49 | |
50 | 50 | public function whereEQ($field, $value, $table_name = null, $bindname = null) |
51 | 51 | { |
52 | - return $this->whereBindField($table_name, $field, self::$OP_EQ, $value, $bindname); |
|
52 | + return $this->whereBindField($table_name, $field, self::$OP_EQ, $value, $bindname); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function whereGT($field, $value, $table_name = null, $bindname = null) |
56 | 56 | { |
57 | - return $this->whereBindField($table_name, $field, self::$OP_GT, $value, $bindname); |
|
57 | + return $this->whereBindField($table_name, $field, self::$OP_GT, $value, $bindname); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function whereLT($field, $value, $table_name = null, $bindname = null) |
61 | 61 | { |
62 | - return $this->whereBindField($table_name, $field, self::$OP_LT, $value, $bindname); |
|
62 | + return $this->whereBindField($table_name, $field, self::$OP_LT, $value, $bindname); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function whereGTE($field, $value, $table_name = null, $bindname = null) |
66 | 66 | { |
67 | - return $this->whereBindField($table_name, $field, self::$OP_GTE, $value, $bindname); |
|
67 | + return $this->whereBindField($table_name, $field, self::$OP_GTE, $value, $bindname); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function whereLTE($field, $value, $table_name = null, $bindname = null) |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @param $filters_operator Object, inclusive or exclusive search |
172 | 172 | */ |
173 | 173 | |
174 | - // sub array filters[$content] |
|
174 | + // sub array filters[$content] |
|
175 | 175 | public function whereFilterContent($filters_content, $search_table = null, $filters_operator = null) |
176 | 176 | { |
177 | 177 | if (!isset($filters_content['term']) || !isset($filters_content['fields'])) { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $in = ''; |
133 | 133 | foreach ($values as $i => $v) { |
134 | 134 | // TODO dirty patching. mathematical certainty needed |
135 | - $placeholder_name = ':' . $table_name . '_' . $field . '_awS_in_' . $count_values . '_' . $i; |
|
135 | + $placeholder_name = ':'.$table_name.'_'.$field.'_awS_in_'.$count_values.'_'.$i; |
|
136 | 136 | $this->addBinding($field, $v, null, $placeholder_name); |
137 | 137 | $in .= "$placeholder_name,"; |
138 | 138 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function generateWhere() |
232 | 232 | { |
233 | 233 | if (!empty($this->where)) { |
234 | - return PHP_EOL . ' WHERE ' . implode(PHP_EOL . ' AND ', $this->where); |
|
234 | + return PHP_EOL.' WHERE '.implode(PHP_EOL.' AND ', $this->where); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -142,25 +142,25 @@ |
||
142 | 142 | |
143 | 143 | $query_fields = empty($this->selection) ? ['*'] : $this->selection; |
144 | 144 | |
145 | - $ret = PHP_EOL . 'SELECT ' . implode(', ' . PHP_EOL, $query_fields); |
|
146 | - $ret .= PHP_EOL . sprintf(' FROM `%s` %s ', $this->tableName(), $this->table_alias); |
|
145 | + $ret = PHP_EOL.'SELECT '.implode(', '.PHP_EOL, $query_fields); |
|
146 | + $ret .= PHP_EOL.sprintf(' FROM `%s` %s ', $this->tableName(), $this->table_alias); |
|
147 | 147 | |
148 | 148 | if (!empty($this->join)) { |
149 | - $ret .= PHP_EOL . ' ' . implode(PHP_EOL . ' ', $this->join); |
|
149 | + $ret .= PHP_EOL.' '.implode(PHP_EOL.' ', $this->join); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $ret .= $this->generateWhere(); |
153 | 153 | |
154 | 154 | foreach (['group' => 'GROUP BY', 'having' => 'HAVING', 'order' => 'ORDER BY'] as $part => $prefix) { |
155 | 155 | if (!empty($this->$part)) { |
156 | - $ret .= PHP_EOL . " $prefix " . implode(', ', $this->$part); |
|
156 | + $ret .= PHP_EOL." $prefix ".implode(', ', $this->$part); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | 160 | if (!empty($this->limit_number)) { |
161 | 161 | $offset = $this->limit_offset ?? 0; |
162 | 162 | $number = $this->limit_number; |
163 | - $ret .= PHP_EOL . " LIMIT $offset, $number"; |
|
163 | + $ret .= PHP_EOL." LIMIT $offset, $number"; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return $ret; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | 'REFERENCED_COLUMN_NAME' |
46 | 46 | ]; |
47 | 47 | |
48 | - $statement = 'SELECT ' . implode(', ', $fields) |
|
48 | + $statement = 'SELECT '.implode(', ', $fields) |
|
49 | 49 | . ' FROM KEY_COLUMN_USAGE' |
50 | 50 | . ' WHERE TABLE_SCHEMA = "%s"' |
51 | 51 | . ' ORDER BY TABLE_NAME, CONSTRAINT_NAME, ORDINAL_POSITION'; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | try { |
33 | 33 | return self::$database->inspect($table_name); |
34 | 34 | } catch (\Exception $e) { |
35 | - throw new CruditesException('TABLE_INTROSPECTION::' . $table_name); |
|
35 | + throw new CruditesException('TABLE_INTROSPECTION::'.$table_name); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 |