@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function import($assoc_data) |
46 | 46 | { |
47 | 47 | if (!is_array($assoc_data)) { |
48 | - throw new \Exception(__FUNCTION__ . '(assoc_data) parm is not an array'); |
|
48 | + throw new \Exception(__FUNCTION__.'(assoc_data) parm is not an array'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // shove it all up in model, god will sort them out |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | if ($table_name === false) { |
74 | 74 | $calling_class = $reflect->getShortName(); |
75 | - if (defined($const_name = 'TABLE_' . strtoupper($calling_class))) { |
|
75 | + if (defined($const_name = 'TABLE_'.strtoupper($calling_class))) { |
|
76 | 76 | $table_name = constant($const_name); |
77 | 77 | } else { |
78 | 78 | $table_name = strtolower($calling_class); |
@@ -113,50 +113,50 @@ discard block |
||
113 | 113 | $Query = $table->select(null, $class::table_alias()); |
114 | 114 | |
115 | 115 | |
116 | - if(!isset($options['eager']) || $options['eager'] !== false) |
|
116 | + if (!isset($options['eager']) || $options['eager'] !== false) |
|
117 | 117 | { |
118 | 118 | $Query->eager(); |
119 | 119 | } |
120 | 120 | |
121 | 121 | |
122 | - foreach($table->columns() as $column_name => $column) |
|
122 | + foreach ($table->columns() as $column_name => $column) |
|
123 | 123 | { |
124 | - if(isset($filters[$column_name]) && is_string($filters[$column_name])) |
|
124 | + if (isset($filters[$column_name]) && is_string($filters[$column_name])) |
|
125 | 125 | $Query->aw_eq($column_name, $filters[$column_name]); |
126 | 126 | } |
127 | 127 | |
128 | - if(is_subclass_of($event = new $class(), '\HexMakina\kadro\Models\Interfaces\EventInterface')) |
|
128 | + if (is_subclass_of($event = new $class(), '\HexMakina\kadro\Models\Interfaces\EventInterface')) |
|
129 | 129 | { |
130 | - if(!empty($filters['date_start'])) |
|
130 | + if (!empty($filters['date_start'])) |
|
131 | 131 | $Query->aw_gte($event->event_field(), $filters['date_start'], $Query->table_label(), ':filter_date_start'); |
132 | 132 | |
133 | - if(!empty($filters['date_stop'])) |
|
133 | + if (!empty($filters['date_stop'])) |
|
134 | 134 | $Query->aw_lte($event->event_field(), $filters['date_stop'], $Query->table_label(), ':filter_date_stop'); |
135 | 135 | |
136 | - if(empty($options['order_by'])) |
|
136 | + if (empty($options['order_by'])) |
|
137 | 137 | $Query->order_by([$event->event_field(), 'DESC']); |
138 | 138 | } |
139 | 139 | |
140 | - if(isset($filters['content'])) $Query->aw_filter_content($filters['content']); |
|
140 | + if (isset($filters['content'])) $Query->aw_filter_content($filters['content']); |
|
141 | 141 | |
142 | - if(isset($filters['ids'])) |
|
142 | + if (isset($filters['ids'])) |
|
143 | 143 | { |
144 | - if(empty($filters['ids'])) |
|
144 | + if (empty($filters['ids'])) |
|
145 | 145 | $Query->and_where('1=0'); // TODO: this is a new low.. find another way to cancel query |
146 | 146 | else $Query->aw_numeric_in('id', $filters['ids'], $Query->table_label()); |
147 | 147 | } |
148 | 148 | |
149 | - if(isset($options['order_by'])) // TODO commenting required about the array situation |
|
149 | + if (isset($options['order_by'])) // TODO commenting required about the array situation |
|
150 | 150 | { |
151 | 151 | $order_by = $options['order_by']; |
152 | 152 | |
153 | - if(is_string($order_by)) |
|
153 | + if (is_string($order_by)) |
|
154 | 154 | $Query->order_by($order_by); |
155 | 155 | |
156 | - elseif(is_array($order_by)) |
|
157 | - foreach($options['order_by'] as $order_by) |
|
156 | + elseif (is_array($order_by)) |
|
157 | + foreach ($options['order_by'] as $order_by) |
|
158 | 158 | { |
159 | - if(!isset($order_by[2])) |
|
159 | + if (!isset($order_by[2])) |
|
160 | 160 | array_unshift($order_by, ''); |
161 | 161 | |
162 | 162 | list($order_table, $order_field, $order_direction) = $order_by; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - if(isset($options['limit']) && is_array($options['limit'])) |
|
167 | + if (isset($options['limit']) && is_array($options['limit'])) |
|
168 | 168 | $Query->limit($options['limit'][1], $options['limit'][0]); |
169 | 169 | |
170 | 170 | return $Query; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $ret = []; |
179 | 179 | $pk_name = implode('_', array_keys($Query->table()->primary_keys())); |
180 | 180 | |
181 | - if (count($pks = $Query->table()->primary_keys()) > 1) { |
|
181 | + if (count($pks = $Query->table()->primary_keys())>1) { |
|
182 | 182 | $concat_pk = sprintf('CONCAT(%s) as %s', implode(',', $pks), $pk_name); |
183 | 183 | $Query->select_also([$concat_pk]); |
184 | 184 | } |