Completed
Push — master ( 876d80...2ae423 )
by Ahmet
02:54
created
src/qb.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function whereOr()
92 92
     {
93
-        $this->_conditions[] = '('.implode(' or ', func_get_args()).')';
93
+        $this->_conditions[] = '(' . implode(' or ', func_get_args()) . ')';
94 94
 
95 95
         return $this;
96 96
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
     public function getSelect()
136 136
     {
137
-		if(count($this->_table_names) == 0) {
137
+		if (count($this->_table_names) == 0) {
138 138
 			throw new exception('Specify at least 1 table name');
139 139
 		}
140 140
         $_read_fields = $this->_read_fields;
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
         }
144 144
         $limit = null;
145 145
         if ($this->limit > 0) {
146
-            $limit = ' limit '.($this->limit_offset != -1 ? $this->limit_offset.', ' : null).$this->limit;
146
+            $limit = ' limit ' . ($this->limit_offset != -1 ? $this->limit_offset . ', ' : null) . $this->limit;
147 147
         }
148 148
         $group = null;
149 149
         if (count($this->_group_fields) > 0) {
150
-            $group = ' group by '.implode(', ', $this->_group_fields).' ';
150
+            $group = ' group by ' . implode(', ', $this->_group_fields) . ' ';
151 151
         }
152 152
         $order = null;
153 153
         if (count($this->_order_fields) > 0) {
@@ -159,38 +159,38 @@  discard block
 block discarded – undo
159 159
                     $pos = strpos($of[0], '.');
160 160
                     if ($pos !== false) {
161 161
                         $t = explode('.', $of[0]);
162
-                        $t[1] = '`'.$t[1].'`';
162
+                        $t[1] = '`' . $t[1] . '`';
163 163
                         $of[0] = implode('.', $t);
164 164
                         $order .= $of[0];
165 165
                     } else {
166
-                        $order .= '`'.$of[0].'`';
166
+                        $order .= '`' . $of[0] . '`';
167 167
                     }
168
-                    $order .= ' '.($of[1] ? 'asc' : 'desc');
168
+                    $order .= ' ' . ($of[1] ? 'asc' : 'desc');
169 169
                 } else {
170 170
                     $order .= $of[0];
171 171
                 }
172 172
                 ++$i;
173 173
             }
174 174
         }
175
-        $string = sprintf('select %1$s from %2$s%3$s%6$s%4$s%5$s', implode(', ', $_read_fields), implode(', ', $this->_table_names), count($this->_conditions) > 0 ? (' where '.implode(' and ', $this->_conditions)) : null, $order, $limit, $group);
175
+        $string = sprintf('select %1$s from %2$s%3$s%6$s%4$s%5$s', implode(', ', $_read_fields), implode(', ', $this->_table_names), count($this->_conditions) > 0 ? (' where ' . implode(' and ', $this->_conditions)) : null, $order, $limit, $group);
176 176
 
177 177
         return $string;
178 178
     }
179 179
 
180 180
     public function getUpdate()
181 181
     {
182
-		if(count($this->_table_names) == 0) {
182
+		if (count($this->_table_names) == 0) {
183 183
 			throw new exception('Specify at least 1 table name');
184 184
 		}
185
-		if(count($this->_write_fields) == 0) {
185
+		if (count($this->_write_fields) == 0) {
186 186
 			throw new exception('Specify at least 1 write field (set function)');
187 187
 		}
188 188
         $updates = array();
189 189
         for ($d = 0, $m = count($this->_write_fields); $d < $m; ++$d) {
190
-            $t = $this->_write_fields[$d].'=';
190
+            $t = $this->_write_fields[$d] . '=';
191 191
             switch ($this->_write_field_types[$d]) {
192 192
             case 0:
193
-              $t .= "'".$this->_write_values[$d]."'";
193
+              $t .= "'" . $this->_write_values[$d] . "'";
194 194
               break;
195 195
           default:
196 196
               $t .= $this->_write_values[$d];
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
         $update_fields = implode(', ', $updates);
201 201
         $limit = null;
202 202
         if ($this->limit > 0) {
203
-            $limit = ' limit '.($this->limit_offset != -1 ? $this->limit_offset.', ' : null).$this->limit;
203
+            $limit = ' limit ' . ($this->limit_offset != -1 ? $this->limit_offset . ', ' : null) . $this->limit;
204 204
         }
205
-        $where = count($this->_conditions) > 0 ? (' where '.implode(' and ', $this->_conditions)) : null;
205
+        $where = count($this->_conditions) > 0 ? (' where ' . implode(' and ', $this->_conditions)) : null;
206 206
         $string = sprintf('update %1$s set %2$s %3$s %4$s', $this->_table_names[0], $update_fields, $where, $limit);
207 207
 
208 208
         return $string;
@@ -210,19 +210,19 @@  discard block
 block discarded – undo
210 210
 
211 211
     public function getInsert()
212 212
     {
213
-		if(count($this->_table_names) == 0) {
213
+		if (count($this->_table_names) == 0) {
214 214
 			throw new exception('Specify at least 1 table name');
215 215
 		}
216
-		if(count($this->_write_fields) == 0) {
216
+		if (count($this->_write_fields) == 0) {
217 217
 			throw new exception('Specify at least 1 write field (set function)');
218 218
 		}
219 219
         $table = $this->_table_names[0];
220
-        $fields = '`'.implode('`, `', $this->_write_fields).'`';
220
+        $fields = '`' . implode('`, `', $this->_write_fields) . '`';
221 221
         $values = array();
222 222
         for ($d = 0, $m = count($this->_write_fields); $d < $m; ++$d) {
223 223
             switch ($this->_write_field_types[$d]) {
224 224
             case 0:
225
-              $values[] = "'".$this->_write_values[$d]."'";
225
+              $values[] = "'" . $this->_write_values[$d] . "'";
226 226
               break;
227 227
             default:
228 228
               $values[] = $this->_write_values[$d];
@@ -235,14 +235,14 @@  discard block
 block discarded – undo
235 235
 
236 236
     public function getDelete()
237 237
     {
238
-		if(count($this->_table_names) == 0) {
238
+		if (count($this->_table_names) == 0) {
239 239
 			throw new exception('Specify at least 1 table name');
240 240
 		}
241 241
         $table = $this->_table_names[0];
242
-        $where = count($this->_conditions) > 0 ? (' where '.implode(' and ', $this->_conditions)) : null;
242
+        $where = count($this->_conditions) > 0 ? (' where ' . implode(' and ', $this->_conditions)) : null;
243 243
         $limit = null;
244 244
         if ($this->limit > 0) {
245
-            $limit = ' limit '.($this->limit_offset != -1 ? $this->limit_offset.', ' : null).$this->limit;
245
+            $limit = ' limit ' . ($this->limit_offset != -1 ? $this->limit_offset . ', ' : null) . $this->limit;
246 246
         }
247 247
         $string = sprintf('delete from %1$s %2$s %3$s', $table, $where, $limit);
248 248
 
Please login to merge, or discard this patch.