@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | class ezSQLcore |
28 | 28 | { |
29 | 29 | |
30 | - var $trace = false; // same as $debug_all |
|
31 | - var $debug_all = false; // same as $trace |
|
30 | + var $trace = false; // same as $debug_all |
|
31 | + var $debug_all = false; // same as $trace |
|
32 | 32 | var $debug_called = false; |
33 | 33 | var $vardump_called = false; |
34 | 34 | var $show_errors = true; |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * Returns array of host and port. If port is omitted, returns $default |
69 | 69 | */ |
70 | 70 | |
71 | - function get_host_port( $host, $default = false ) |
|
71 | + function get_host_port($host, $default = false) |
|
72 | 72 | { |
73 | 73 | $port = $default; |
74 | - if ( false !== strpos( $host, ':' ) ) { |
|
75 | - list( $host, $port ) = explode( ':', $host ); |
|
74 | + if (false !== strpos($host, ':')) { |
|
75 | + list($host, $port) = explode(':', $host); |
|
76 | 76 | $port = (int) $port; |
77 | 77 | } |
78 | - return array( $host, $port ); |
|
78 | + return array($host, $port); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /********************************************************************** |
@@ -88,8 +88,7 @@ discard block |
||
88 | 88 | $this->last_error = $err_str; |
89 | 89 | |
90 | 90 | // Capture all errors to an error array no matter what happens |
91 | - $this->captured_errors[] = array |
|
92 | - ( |
|
91 | + $this->captured_errors[] = array( |
|
93 | 92 | 'error_str' => $err_str, |
94 | 93 | 'query' => $this->last_query |
95 | 94 | ); |
@@ -126,63 +125,63 @@ discard block |
||
126 | 125 | * Get one variable from the DB - see docs for more detail |
127 | 126 | */ |
128 | 127 | |
129 | - function get_var($query=null,$x=0,$y=0) |
|
128 | + function get_var($query = null, $x = 0, $y = 0) |
|
130 | 129 | { |
131 | 130 | |
132 | 131 | // Log how the function was called |
133 | 132 | $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; |
134 | 133 | |
135 | 134 | // If there is a query then perform it if not then use cached results.. |
136 | - if ( $query ) |
|
135 | + if ($query) |
|
137 | 136 | { |
138 | 137 | $this->query($query); |
139 | 138 | } |
140 | 139 | |
141 | 140 | // Extract var out of cached results based x,y vals |
142 | - if ( $this->last_result[$y] ) |
|
141 | + if ($this->last_result[$y]) |
|
143 | 142 | { |
144 | 143 | $values = array_values(get_object_vars($this->last_result[$y])); |
145 | 144 | } |
146 | 145 | |
147 | 146 | // If there is a value return it else return null |
148 | - return (isset($values[$x]) && $values[$x]!=='')?$values[$x]:null; |
|
147 | + return (isset($values[$x]) && $values[$x] !== '') ? $values[$x] : null; |
|
149 | 148 | } |
150 | 149 | |
151 | 150 | /********************************************************************** |
152 | 151 | * Get one row from the DB - see docs for more detail |
153 | 152 | */ |
154 | 153 | |
155 | - function get_row($query=null,$output=OBJECT,$y=0) |
|
154 | + function get_row($query = null, $output = OBJECT, $y = 0) |
|
156 | 155 | { |
157 | 156 | |
158 | 157 | // Log how the function was called |
159 | 158 | $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; |
160 | 159 | |
161 | 160 | // If there is a query then perform it if not then use cached results.. |
162 | - if ( $query ) |
|
161 | + if ($query) |
|
163 | 162 | { |
164 | 163 | $this->query($query); |
165 | 164 | } |
166 | 165 | |
167 | 166 | // If the output is an object then return object using the row offset.. |
168 | - if ( $output == OBJECT ) |
|
167 | + if ($output == OBJECT) |
|
169 | 168 | { |
170 | - return $this->last_result[$y]?$this->last_result[$y]:null; |
|
169 | + return $this->last_result[$y] ? $this->last_result[$y] : null; |
|
171 | 170 | } |
172 | 171 | // If the output is an associative array then return row as such.. |
173 | - elseif ( $output == ARRAY_A ) |
|
172 | + elseif ($output == ARRAY_A) |
|
174 | 173 | { |
175 | - return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null; |
|
174 | + return $this->last_result[$y] ?get_object_vars($this->last_result[$y]) : null; |
|
176 | 175 | } |
177 | 176 | // If the output is an numerical array then return row as such.. |
178 | - elseif ( $output == ARRAY_N ) |
|
177 | + elseif ($output == ARRAY_N) |
|
179 | 178 | { |
180 | - return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null; |
|
179 | + return $this->last_result[$y] ?array_values(get_object_vars($this->last_result[$y])) : null; |
|
181 | 180 | } |
182 | 181 | // If invalid output type was specified.. |
183 | 182 | else |
184 | 183 | { |
185 | - $this->show_errors ? trigger_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N",E_USER_WARNING) : null; |
|
184 | + $this->show_errors ? trigger_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N", E_USER_WARNING) : null; |
|
186 | 185 | } |
187 | 186 | |
188 | 187 | } |
@@ -192,22 +191,22 @@ discard block |
||
192 | 191 | * see docs for usage and info |
193 | 192 | */ |
194 | 193 | |
195 | - function get_col($query=null,$x=0) |
|
194 | + function get_col($query = null, $x = 0) |
|
196 | 195 | { |
197 | 196 | |
198 | 197 | $new_array = array(); |
199 | 198 | |
200 | 199 | // If there is a query then perform it if not then use cached results.. |
201 | - if ( $query ) |
|
200 | + if ($query) |
|
202 | 201 | { |
203 | 202 | $this->query($query); |
204 | 203 | } |
205 | 204 | |
206 | 205 | // Extract the column values |
207 | 206 | $j = count($this->last_result); |
208 | - for ( $i=0; $i < $j; $i++ ) |
|
207 | + for ($i = 0; $i < $j; $i++) |
|
209 | 208 | { |
210 | - $new_array[$i] = $this->get_var(null,$x,$i); |
|
209 | + $new_array[$i] = $this->get_var(null, $x, $i); |
|
211 | 210 | } |
212 | 211 | |
213 | 212 | return $new_array; |
@@ -218,34 +217,34 @@ discard block |
||
218 | 217 | * Return the the query as a result set - see docs for more details |
219 | 218 | */ |
220 | 219 | |
221 | - function get_results($query=null, $output = OBJECT) |
|
220 | + function get_results($query = null, $output = OBJECT) |
|
222 | 221 | { |
223 | 222 | |
224 | 223 | // Log how the function was called |
225 | 224 | $this->func_call = "\$db->get_results(\"$query\", $output)"; |
226 | 225 | |
227 | 226 | // If there is a query then perform it if not then use cached results.. |
228 | - if ( $query ) |
|
227 | + if ($query) |
|
229 | 228 | { |
230 | 229 | $this->query($query); |
231 | 230 | } |
232 | 231 | |
233 | 232 | // Send back array of objects. Each row is an object |
234 | - if ( $output == OBJECT ) |
|
233 | + if ($output == OBJECT) |
|
235 | 234 | { |
236 | 235 | return $this->last_result; |
237 | 236 | } |
238 | - elseif ( $output == ARRAY_A || $output == ARRAY_N ) |
|
237 | + elseif ($output == ARRAY_A || $output == ARRAY_N) |
|
239 | 238 | { |
240 | - if ( $this->last_result ) |
|
239 | + if ($this->last_result) |
|
241 | 240 | { |
242 | - $i=0; |
|
243 | - foreach( $this->last_result as $row ) |
|
241 | + $i = 0; |
|
242 | + foreach ($this->last_result as $row) |
|
244 | 243 | { |
245 | 244 | |
246 | 245 | $new_array[$i] = get_object_vars($row); |
247 | 246 | |
248 | - if ( $output == ARRAY_N ) |
|
247 | + if ($output == ARRAY_N) |
|
249 | 248 | { |
250 | 249 | $new_array[$i] = array_values($new_array[$i]); |
251 | 250 | } |
@@ -268,15 +267,15 @@ discard block |
||
268 | 267 | * see docs for more info and usage |
269 | 268 | */ |
270 | 269 | |
271 | - function get_col_info($info_type="name",$col_offset=-1) |
|
270 | + function get_col_info($info_type = "name", $col_offset = -1) |
|
272 | 271 | { |
273 | 272 | |
274 | - if ( $this->col_info ) |
|
273 | + if ($this->col_info) |
|
275 | 274 | { |
276 | - if ( $col_offset == -1 ) |
|
275 | + if ($col_offset == -1) |
|
277 | 276 | { |
278 | - $i=0; |
|
279 | - foreach($this->col_info as $col ) |
|
277 | + $i = 0; |
|
278 | + foreach ($this->col_info as $col) |
|
280 | 279 | { |
281 | 280 | $new_array[$i] = $col->{$info_type}; |
282 | 281 | $i++; |
@@ -296,33 +295,32 @@ discard block |
||
296 | 295 | * store_cache |
297 | 296 | */ |
298 | 297 | |
299 | - function store_cache($query,$is_insert) |
|
298 | + function store_cache($query, $is_insert) |
|
300 | 299 | { |
301 | 300 | |
302 | 301 | // The would be cache file for this query |
303 | 302 | $cache_file = $this->cache_dir.'/'.md5($query); |
304 | 303 | |
305 | 304 | // disk caching of queries |
306 | - if ( $this->use_disk_cache && ( $this->cache_queries && ! $is_insert ) || ( $this->cache_inserts && $is_insert )) |
|
305 | + if ($this->use_disk_cache && ($this->cache_queries && ! $is_insert) || ($this->cache_inserts && $is_insert)) |
|
307 | 306 | { |
308 | - if ( ! is_dir($this->cache_dir) ) |
|
307 | + if ( ! is_dir($this->cache_dir)) |
|
309 | 308 | { |
310 | 309 | $this->register_error("Could not open cache dir: $this->cache_dir"); |
311 | - $this->show_errors ? trigger_error("Could not open cache dir: $this->cache_dir",E_USER_WARNING) : null; |
|
310 | + $this->show_errors ? trigger_error("Could not open cache dir: $this->cache_dir", E_USER_WARNING) : null; |
|
312 | 311 | } |
313 | 312 | else |
314 | 313 | { |
315 | 314 | // Cache all result values |
316 | - $result_cache = array |
|
317 | - ( |
|
315 | + $result_cache = array( |
|
318 | 316 | 'col_info' => $this->col_info, |
319 | 317 | 'last_result' => $this->last_result, |
320 | 318 | 'num_rows' => $this->num_rows, |
321 | 319 | 'return_value' => $this->num_rows, |
322 | 320 | ); |
323 | 321 | file_put_contents($cache_file, serialize($result_cache)); |
324 | - if( file_exists($cache_file . ".updating") ) |
|
325 | - unlink($cache_file . ".updating"); |
|
322 | + if (file_exists($cache_file.".updating")) |
|
323 | + unlink($cache_file.".updating"); |
|
326 | 324 | } |
327 | 325 | } |
328 | 326 | |
@@ -339,13 +337,13 @@ discard block |
||
339 | 337 | $cache_file = $this->cache_dir.'/'.md5($query); |
340 | 338 | |
341 | 339 | // Try to get previously cached version |
342 | - if ( $this->use_disk_cache && file_exists($cache_file) ) |
|
340 | + if ($this->use_disk_cache && file_exists($cache_file)) |
|
343 | 341 | { |
344 | 342 | // Only use this cache file if less than 'cache_timeout' (hours) |
345 | - if ( (time() - filemtime($cache_file)) > ($this->cache_timeout*3600) && |
|
346 | - !(file_exists($cache_file . ".updating") && (time() - filemtime($cache_file . ".updating") < 60)) ) |
|
343 | + if ((time() - filemtime($cache_file)) > ($this->cache_timeout * 3600) && |
|
344 | + ! (file_exists($cache_file.".updating") && (time() - filemtime($cache_file.".updating") < 60))) |
|
347 | 345 | { |
348 | - touch($cache_file . ".updating"); // Show that we in the process of updating the cache |
|
346 | + touch($cache_file.".updating"); // Show that we in the process of updating the cache |
|
349 | 347 | } |
350 | 348 | else |
351 | 349 | { |
@@ -358,7 +356,7 @@ discard block |
||
358 | 356 | $this->from_disk_cache = true; |
359 | 357 | |
360 | 358 | // If debug ALL queries |
361 | - $this->trace || $this->debug_all ? $this->debug() : null ; |
|
359 | + $this->trace || $this->debug_all ? $this->debug() : null; |
|
362 | 360 | |
363 | 361 | return $result_cache['return_value']; |
364 | 362 | } |
@@ -371,7 +369,7 @@ discard block |
||
371 | 369 | * formatted and easy to understand way - any type: Object, Var or Array |
372 | 370 | */ |
373 | 371 | |
374 | - function vardump($mixed='') |
|
372 | + function vardump($mixed = '') |
|
375 | 373 | { |
376 | 374 | |
377 | 375 | // Start outup buffering |
@@ -380,16 +378,16 @@ discard block |
||
380 | 378 | echo "<p><table><tr><td bgcolor=ffffff><blockquote><font color=000090>"; |
381 | 379 | echo "<pre><font face=arial>"; |
382 | 380 | |
383 | - if ( ! $this->vardump_called ) |
|
381 | + if ( ! $this->vardump_called) |
|
384 | 382 | { |
385 | 383 | echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n"; |
386 | 384 | } |
387 | 385 | |
388 | - $var_type = gettype ($mixed); |
|
389 | - print_r(($mixed?$mixed:"<font color=red>No Value / False</font>")); |
|
390 | - echo "\n\n<b>Type:</b> " . ucfirst($var_type) . "\n"; |
|
391 | - echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query?$this->last_query:"NULL")."\n"; |
|
392 | - echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n"; |
|
386 | + $var_type = gettype($mixed); |
|
387 | + print_r(($mixed ? $mixed : "<font color=red>No Value / False</font>")); |
|
388 | + echo "\n\n<b>Type:</b> ".ucfirst($var_type)."\n"; |
|
389 | + echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query ? $this->last_query : "NULL")."\n"; |
|
390 | + echo "<b>Last Function Call:</b> ".($this->func_call ? $this->func_call : "None")."\n"; |
|
393 | 391 | echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n"; |
394 | 392 | echo "</font></pre></font></blockquote></td></tr></table>".$this->donation(); |
395 | 393 | echo "\n<hr size=1 noshade color=dddddd>"; |
@@ -399,7 +397,7 @@ discard block |
||
399 | 397 | ob_end_clean(); |
400 | 398 | |
401 | 399 | // Only echo output if it is turned on |
402 | - if ( $this->debug_echo_is_on ) |
|
400 | + if ($this->debug_echo_is_on) |
|
403 | 401 | { |
404 | 402 | echo $html; |
405 | 403 | } |
@@ -425,7 +423,7 @@ discard block |
||
425 | 423 | * (abstracted into a seperate file to save server overhead). |
426 | 424 | */ |
427 | 425 | |
428 | - function debug($print_to_screen=true) |
|
426 | + function debug($print_to_screen = true) |
|
429 | 427 | { |
430 | 428 | |
431 | 429 | // Start outup buffering |
@@ -434,17 +432,17 @@ discard block |
||
434 | 432 | echo "<blockquote>"; |
435 | 433 | |
436 | 434 | // Only show ezSQL credits once.. |
437 | - if ( ! $this->debug_called ) |
|
435 | + if ( ! $this->debug_called) |
|
438 | 436 | { |
439 | 437 | echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n"; |
440 | 438 | } |
441 | 439 | |
442 | - if ( $this->last_error ) |
|
440 | + if ($this->last_error) |
|
443 | 441 | { |
444 | 442 | echo "<font face=arial size=2 color=000099><b>Last Error --</b> [<font color=000000><b>$this->last_error</b></font>]<p>"; |
445 | 443 | } |
446 | 444 | |
447 | - if ( $this->from_disk_cache ) |
|
445 | + if ($this->from_disk_cache) |
|
448 | 446 | { |
449 | 447 | echo "<font face=arial size=2 color=000099><b>Results retrieved from disk cache</b></font><p>"; |
450 | 448 | } |
@@ -455,7 +453,7 @@ discard block |
||
455 | 453 | echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>"; |
456 | 454 | echo "<blockquote>"; |
457 | 455 | |
458 | - if ( $this->col_info ) |
|
456 | + if ($this->col_info) |
|
459 | 457 | { |
460 | 458 | |
461 | 459 | // ===================================================== |
@@ -465,11 +463,11 @@ discard block |
||
465 | 463 | echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>"; |
466 | 464 | |
467 | 465 | |
468 | - for ( $i=0, $j=count($this->col_info); $i < $j; $i++ ) |
|
466 | + for ($i = 0, $j = count($this->col_info); $i < $j; $i++) |
|
469 | 467 | { |
470 | 468 | /* when selecting count(*) the maxlengh is not set, size is set instead. */ |
471 | 469 | echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type}"; |
472 | - if (!isset($this->col_info[$i]->max_length)) |
|
470 | + if ( ! isset($this->col_info[$i]->max_length)) |
|
473 | 471 | { |
474 | 472 | echo "{$this->col_info[$i]->size}"; |
475 | 473 | } else { |
@@ -483,16 +481,16 @@ discard block |
||
483 | 481 | // ====================================================== |
484 | 482 | // print main results |
485 | 483 | |
486 | - if ( $this->last_result ) |
|
484 | + if ($this->last_result) |
|
487 | 485 | { |
488 | 486 | |
489 | - $i=0; |
|
490 | - foreach ( $this->get_results(null,ARRAY_N) as $one_row ) |
|
487 | + $i = 0; |
|
488 | + foreach ($this->get_results(null, ARRAY_N) as $one_row) |
|
491 | 489 | { |
492 | 490 | $i++; |
493 | 491 | echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>"; |
494 | 492 | |
495 | - foreach ( $one_row as $item ) |
|
493 | + foreach ($one_row as $item) |
|
496 | 494 | { |
497 | 495 | echo "<td nowrap><font face=arial size=2>$item</font></td>"; |
498 | 496 | } |
@@ -503,7 +501,7 @@ discard block |
||
503 | 501 | } // if last result |
504 | 502 | else |
505 | 503 | { |
506 | - echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>"; |
|
504 | + echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info) + 1)."><font face=arial size=2>No Results</font></td></tr>"; |
|
507 | 505 | } |
508 | 506 | |
509 | 507 | echo "</table>"; |
@@ -521,7 +519,7 @@ discard block |
||
521 | 519 | ob_end_clean(); |
522 | 520 | |
523 | 521 | // Only echo output if it is turned on |
524 | - if ( $this->debug_echo_is_on && $print_to_screen) |
|
522 | + if ($this->debug_echo_is_on && $print_to_screen) |
|
525 | 523 | { |
526 | 524 | echo $html; |
527 | 525 | } |
@@ -547,8 +545,8 @@ discard block |
||
547 | 545 | |
548 | 546 | function timer_get_cur() |
549 | 547 | { |
550 | - list($usec, $sec) = explode(" ",microtime()); |
|
551 | - return ((float)$usec + (float)$sec); |
|
548 | + list($usec, $sec) = explode(" ", microtime()); |
|
549 | + return ((float) $usec + (float) $sec); |
|
552 | 550 | } |
553 | 551 | |
554 | 552 | function timer_start($timer_name) |
@@ -558,15 +556,14 @@ discard block |
||
558 | 556 | |
559 | 557 | function timer_elapsed($timer_name) |
560 | 558 | { |
561 | - return round($this->timer_get_cur() - $this->timers[$timer_name],2); |
|
559 | + return round($this->timer_get_cur() - $this->timers[$timer_name], 2); |
|
562 | 560 | } |
563 | 561 | |
564 | 562 | function timer_update_global($timer_name) |
565 | 563 | { |
566 | - if ( $this->do_profile ) |
|
564 | + if ($this->do_profile) |
|
567 | 565 | { |
568 | - $this->profile_times[] = array |
|
569 | - ( |
|
566 | + $this->profile_times[] = array( |
|
570 | 567 | 'query' => $this->last_query, |
571 | 568 | 'time' => $this->timer_elapsed($timer_name) |
572 | 569 | ); |
@@ -595,30 +592,30 @@ discard block |
||
595 | 592 | |
596 | 593 | function get_set($params) |
597 | 594 | { |
598 | - if( !is_array( $params ) ) |
|
595 | + if ( ! is_array($params)) |
|
599 | 596 | { |
600 | - $this->register_error( 'get_set() parameter invalid. Expected array in '.__FILE__.' on line '.__LINE__); |
|
597 | + $this->register_error('get_set() parameter invalid. Expected array in '.__FILE__.' on line '.__LINE__); |
|
601 | 598 | return; |
602 | 599 | } |
603 | 600 | $sql = array(); |
604 | - foreach ( $params as $field => $val ) |
|
601 | + foreach ($params as $field => $val) |
|
605 | 602 | { |
606 | - if ( $val === 'true' || $val === true ) |
|
603 | + if ($val === 'true' || $val === true) |
|
607 | 604 | $val = 1; |
608 | - if ( $val === 'false' || $val === false ) |
|
605 | + if ($val === 'false' || $val === false) |
|
609 | 606 | $val = 0; |
610 | 607 | |
611 | - switch( $val ){ |
|
608 | + switch ($val) { |
|
612 | 609 | case 'NOW()' : |
613 | 610 | case 'NULL' : |
614 | 611 | $sql[] = "$field = $val"; |
615 | 612 | break; |
616 | 613 | default : |
617 | - $sql[] = "$field = '".$this->escape( $val )."'"; |
|
614 | + $sql[] = "$field = '".$this->escape($val)."'"; |
|
618 | 615 | } |
619 | 616 | } |
620 | 617 | |
621 | - return implode( ', ' , $sql ); |
|
618 | + return implode(', ', $sql); |
|
622 | 619 | } |
623 | 620 | |
624 | 621 | /** |
@@ -628,7 +625,7 @@ discard block |
||
628 | 625 | * @param bool $increase Set to true to increase query count (internal usage) |
629 | 626 | * @return int Returns query count base on $all |
630 | 627 | */ |
631 | - function count ($all = true, $increase = false) { |
|
628 | + function count($all = true, $increase = false) { |
|
632 | 629 | if ($increase) { |
633 | 630 | $this->num_queries++; |
634 | 631 | $this->conn_queries++; |
@@ -234,8 +234,7 @@ discard block |
||
234 | 234 | if ( $output == OBJECT ) |
235 | 235 | { |
236 | 236 | return $this->last_result; |
237 | - } |
|
238 | - elseif ( $output == ARRAY_A || $output == ARRAY_N ) |
|
237 | + } elseif ( $output == ARRAY_A || $output == ARRAY_N ) |
|
239 | 238 | { |
240 | 239 | if ( $this->last_result ) |
241 | 240 | { |
@@ -254,8 +253,7 @@ discard block |
||
254 | 253 | } |
255 | 254 | |
256 | 255 | return $new_array; |
257 | - } |
|
258 | - else |
|
256 | + } else |
|
259 | 257 | { |
260 | 258 | return array(); |
261 | 259 | } |
@@ -282,8 +280,7 @@ discard block |
||
282 | 280 | $i++; |
283 | 281 | } |
284 | 282 | return $new_array; |
285 | - } |
|
286 | - else |
|
283 | + } else |
|
287 | 284 | { |
288 | 285 | return $this->col_info[$col_offset]->{$info_type}; |
289 | 286 | } |
@@ -309,8 +306,7 @@ discard block |
||
309 | 306 | { |
310 | 307 | $this->register_error("Could not open cache dir: $this->cache_dir"); |
311 | 308 | $this->show_errors ? trigger_error("Could not open cache dir: $this->cache_dir",E_USER_WARNING) : null; |
312 | - } |
|
313 | - else |
|
309 | + } else |
|
314 | 310 | { |
315 | 311 | // Cache all result values |
316 | 312 | $result_cache = array |
@@ -321,8 +317,9 @@ discard block |
||
321 | 317 | 'return_value' => $this->num_rows, |
322 | 318 | ); |
323 | 319 | file_put_contents($cache_file, serialize($result_cache)); |
324 | - if( file_exists($cache_file . ".updating") ) |
|
325 | - unlink($cache_file . ".updating"); |
|
320 | + if( file_exists($cache_file . ".updating") ) { |
|
321 | + unlink($cache_file . ".updating"); |
|
322 | + } |
|
326 | 323 | } |
327 | 324 | } |
328 | 325 | |
@@ -346,8 +343,7 @@ discard block |
||
346 | 343 | !(file_exists($cache_file . ".updating") && (time() - filemtime($cache_file . ".updating") < 60)) ) |
347 | 344 | { |
348 | 345 | touch($cache_file . ".updating"); // Show that we in the process of updating the cache |
349 | - } |
|
350 | - else |
|
346 | + } else |
|
351 | 347 | { |
352 | 348 | $result_cache = unserialize(file_get_contents($cache_file)); |
353 | 349 | |
@@ -603,10 +599,12 @@ discard block |
||
603 | 599 | $sql = array(); |
604 | 600 | foreach ( $params as $field => $val ) |
605 | 601 | { |
606 | - if ( $val === 'true' || $val === true ) |
|
607 | - $val = 1; |
|
608 | - if ( $val === 'false' || $val === false ) |
|
609 | - $val = 0; |
|
602 | + if ( $val === 'true' || $val === true ) { |
|
603 | + $val = 1; |
|
604 | + } |
|
605 | + if ( $val === 'false' || $val === false ) { |
|
606 | + $val = 0; |
|
607 | + } |
|
610 | 608 | |
611 | 609 | switch( $val ){ |
612 | 610 | case 'NOW()' : |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * ezSQL error strings - mySQLi |
13 | 13 | */ |
14 | 14 | |
15 | - global $ezsql_mysqli_str; |
|
15 | + global $ezsql_mysqli_str; |
|
16 | 16 | |
17 | 17 | $ezsql_mysqli_str = array |
18 | 18 | ( |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $this->select($this->dbname, $this->encoding); |
186 | 186 | } |
187 | 187 | |
188 | - if ( get_magic_quotes_gpc() ) { |
|
188 | + if ( get_magic_quotes_gpc() ) { |
|
189 | 189 | $str = stripslashes($str); |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | return $this->dbh->escape_string($str); |
193 | 193 | } |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | global $ezsql_mysqli_str; |
16 | 16 | |
17 | - $ezsql_mysqli_str = array |
|
18 | - ( |
|
17 | + $ezsql_mysqli_str = array( |
|
19 | 18 | 1 => 'Require $dbuser and $dbpassword to connect to a database server', |
20 | 19 | 2 => 'Error establishing mySQLi database connection. Correct user/password? Correct hostname? Database server running?', |
21 | 20 | 3 => 'Require $dbname to select a database', |
@@ -27,8 +26,8 @@ discard block |
||
27 | 26 | * ezSQL Database specific class - mySQLi |
28 | 27 | */ |
29 | 28 | |
30 | - if ( ! function_exists ('mysqli_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
31 | - if ( ! class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
29 | + if ( ! function_exists('mysqli_connect')) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
30 | + if ( ! class_exists('ezSQLcore')) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
32 | 31 | |
33 | 32 | class ezSQL_mysqli extends ezSQLcore |
34 | 33 | { |
@@ -46,12 +45,12 @@ discard block |
||
46 | 45 | * same time as initialising the ezSQL_mysqli class |
47 | 46 | */ |
48 | 47 | |
49 | - function __construct($dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $encoding='') |
|
48 | + function __construct($dbuser = '', $dbpassword = '', $dbname = '', $dbhost = 'localhost', $encoding = '') |
|
50 | 49 | { |
51 | 50 | $this->dbuser = $dbuser; |
52 | 51 | $this->dbpassword = $dbpassword; |
53 | 52 | $this->dbname = $dbname; |
54 | - list( $this->dbhost, $this->dbport ) = $this->get_host_port( $dbhost, 3306 ); |
|
53 | + list($this->dbhost, $this->dbport) = $this->get_host_port($dbhost, 3306); |
|
55 | 54 | $this->encoding = $encoding; |
56 | 55 | } |
57 | 56 | |
@@ -60,11 +59,11 @@ discard block |
||
60 | 59 | * and select a mySQL database at the same time |
61 | 60 | */ |
62 | 61 | |
63 | - function quick_connect($dbuser='', $dbpassword='', $dbname='', $dbhost='localhost', $dbport='3306', $encoding='') |
|
62 | + function quick_connect($dbuser = '', $dbpassword = '', $dbname = '', $dbhost = 'localhost', $dbport = '3306', $encoding = '') |
|
64 | 63 | { |
65 | 64 | $return_val = false; |
66 | - if ( ! $this->connect($dbuser, $dbpassword, $dbhost, $dbport) ) ; |
|
67 | - else if ( ! $this->select($dbname,$encoding) ) ; |
|
65 | + if ( ! $this->connect($dbuser, $dbpassword, $dbhost, $dbport)); |
|
66 | + else if ( ! $this->select($dbname, $encoding)); |
|
68 | 67 | else $return_val = true; |
69 | 68 | return $return_val; |
70 | 69 | } |
@@ -73,7 +72,7 @@ discard block |
||
73 | 72 | * Try to connect to mySQL database server |
74 | 73 | */ |
75 | 74 | |
76 | - function connect($dbuser='', $dbpassword='', $dbhost='localhost', $dbport=false) |
|
75 | + function connect($dbuser = '', $dbpassword = '', $dbhost = 'localhost', $dbport = false) |
|
77 | 76 | { |
78 | 77 | global $ezsql_mysqli_str; $return_val = false; |
79 | 78 | |
@@ -81,25 +80,25 @@ discard block |
||
81 | 80 | $this->timer_start('db_connect_time'); |
82 | 81 | |
83 | 82 | // If port not specified (new connection issued), get it |
84 | - if( ! $dbport ) { |
|
85 | - list( $dbhost, $dbport ) = $this->get_host_port( $dbhost, 3306 ); |
|
83 | + if ( ! $dbport) { |
|
84 | + list($dbhost, $dbport) = $this->get_host_port($dbhost, 3306); |
|
86 | 85 | } |
87 | 86 | |
88 | 87 | // Must have a user and a password |
89 | - if ( ! $dbuser ) |
|
88 | + if ( ! $dbuser) |
|
90 | 89 | { |
91 | 90 | $this->register_error($ezsql_mysqli_str[1].' in '.__FILE__.' on line '.__LINE__); |
92 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[1],E_USER_WARNING) : null; |
|
91 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[1], E_USER_WARNING) : null; |
|
93 | 92 | } |
94 | 93 | // Try to establish the server database handle |
95 | 94 | else |
96 | 95 | { |
97 | - $this->dbh = new \Mysqli($dbhost,$dbuser,$dbpassword, '', $dbport); |
|
96 | + $this->dbh = new \Mysqli($dbhost, $dbuser, $dbpassword, '', $dbport); |
|
98 | 97 | // Check for connection problem |
99 | - if( $this->dbh->connect_errno ) |
|
98 | + if ($this->dbh->connect_errno) |
|
100 | 99 | { |
101 | 100 | $this->register_error($ezsql_mysqli_str[2].' in '.__FILE__.' on line '.__LINE__); |
102 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[2],E_USER_WARNING) : null; |
|
101 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[2], E_USER_WARNING) : null; |
|
103 | 102 | } |
104 | 103 | else |
105 | 104 | { |
@@ -120,47 +119,47 @@ discard block |
||
120 | 119 | * Try to select a mySQL database |
121 | 120 | */ |
122 | 121 | |
123 | - function select($dbname='', $encoding='') |
|
122 | + function select($dbname = '', $encoding = '') |
|
124 | 123 | { |
125 | 124 | global $ezsql_mysqli_str; $return_val = false; |
126 | 125 | |
127 | 126 | // Must have a database name |
128 | - if ( ! $dbname ) |
|
127 | + if ( ! $dbname) |
|
129 | 128 | { |
130 | 129 | $this->register_error($ezsql_mysqli_str[3].' in '.__FILE__.' on line '.__LINE__); |
131 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[3],E_USER_WARNING) : null; |
|
130 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[3], E_USER_WARNING) : null; |
|
132 | 131 | } |
133 | 132 | |
134 | 133 | // Must have an active database connection |
135 | - else if ( ! $this->dbh ) |
|
134 | + else if ( ! $this->dbh) |
|
136 | 135 | { |
137 | 136 | $this->register_error($ezsql_mysqli_str[4].' in '.__FILE__.' on line '.__LINE__); |
138 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[4],E_USER_WARNING) : null; |
|
137 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[4], E_USER_WARNING) : null; |
|
139 | 138 | } |
140 | 139 | |
141 | 140 | // Try to connect to the database |
142 | - else if ( !@$this->dbh->select_db($dbname) ) |
|
141 | + else if ( ! @$this->dbh->select_db($dbname)) |
|
143 | 142 | { |
144 | 143 | // Try to get error supplied by mysql if not use our own |
145 | - if ( !$str = @$this->dbh->error) |
|
144 | + if ( ! $str = @$this->dbh->error) |
|
146 | 145 | $str = $ezsql_mysqli_str[5]; |
147 | 146 | |
148 | 147 | $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
149 | - $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
|
148 | + $this->show_errors ? trigger_error($str, E_USER_WARNING) : null; |
|
150 | 149 | } |
151 | 150 | else |
152 | 151 | { |
153 | 152 | $this->dbname = $dbname; |
154 | - if($encoding!='') |
|
153 | + if ($encoding != '') |
|
155 | 154 | { |
156 | - $encoding = strtolower(str_replace("-","",$encoding)); |
|
155 | + $encoding = strtolower(str_replace("-", "", $encoding)); |
|
157 | 156 | $charsets = array(); |
158 | 157 | $result = $this->dbh->query("SHOW CHARACTER SET"); |
159 | - while($row = $result->fetch_array(MYSQLI_ASSOC)) |
|
158 | + while ($row = $result->fetch_array(MYSQLI_ASSOC)) |
|
160 | 159 | { |
161 | 160 | $charsets[] = $row["Charset"]; |
162 | 161 | } |
163 | - if(in_array($encoding,$charsets)){ |
|
162 | + if (in_array($encoding, $charsets)) { |
|
164 | 163 | $this->dbh->set_charset($encoding); |
165 | 164 | } |
166 | 165 | } |
@@ -179,13 +178,13 @@ discard block |
||
179 | 178 | function escape($str) |
180 | 179 | { |
181 | 180 | // If there is no existing database connection then try to connect |
182 | - if ( ! isset($this->dbh) || ! $this->dbh ) |
|
181 | + if ( ! isset($this->dbh) || ! $this->dbh) |
|
183 | 182 | { |
184 | 183 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
185 | 184 | $this->select($this->dbname, $this->encoding); |
186 | 185 | } |
187 | 186 | |
188 | - if ( get_magic_quotes_gpc() ) { |
|
187 | + if (get_magic_quotes_gpc()) { |
|
189 | 188 | $str = stripslashes($str); |
190 | 189 | } |
191 | 190 | |
@@ -210,10 +209,10 @@ discard block |
||
210 | 209 | { |
211 | 210 | |
212 | 211 | // This keeps the connection alive for very long running scripts |
213 | - if ( $this->count(false) >= 500 ) |
|
212 | + if ($this->count(false) >= 500) |
|
214 | 213 | { |
215 | 214 | $this->disconnect(); |
216 | - $this->quick_connect($this->dbuser,$this->dbpassword,$this->dbname,$this->dbhost,$this->dbport,$this->encoding); |
|
215 | + $this->quick_connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport, $this->encoding); |
|
217 | 216 | } |
218 | 217 | |
219 | 218 | // Initialise return |
@@ -238,13 +237,13 @@ discard block |
||
238 | 237 | $this->timer_start($this->num_queries); |
239 | 238 | |
240 | 239 | // Use core file cache function |
241 | - if ( $cache = $this->get_cache($query) ) |
|
240 | + if ($cache = $this->get_cache($query)) |
|
242 | 241 | { |
243 | 242 | // Keep tack of how long all queries have taken |
244 | 243 | $this->timer_update_global($this->num_queries); |
245 | 244 | |
246 | 245 | // Trace all queries |
247 | - if ( $this->use_trace_log ) |
|
246 | + if ($this->use_trace_log) |
|
248 | 247 | { |
249 | 248 | $this->trace_log[] = $this->debug(false); |
250 | 249 | } |
@@ -253,12 +252,12 @@ discard block |
||
253 | 252 | } |
254 | 253 | |
255 | 254 | // If there is no existing database connection then try to connect |
256 | - if ( ! isset($this->dbh) || ! $this->dbh ) |
|
255 | + if ( ! isset($this->dbh) || ! $this->dbh) |
|
257 | 256 | { |
258 | 257 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
259 | - $this->select($this->dbname,$this->encoding); |
|
258 | + $this->select($this->dbname, $this->encoding); |
|
260 | 259 | // No existing connection at this point means the server is unreachable |
261 | - if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) |
|
260 | + if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno) |
|
262 | 261 | return false; |
263 | 262 | } |
264 | 263 | |
@@ -266,21 +265,21 @@ discard block |
||
266 | 265 | $this->result = @$this->dbh->query($query); |
267 | 266 | |
268 | 267 | // If there is an error then take note of it.. |
269 | - if ( $str = @$this->dbh->error ) |
|
268 | + if ($str = @$this->dbh->error) |
|
270 | 269 | { |
271 | 270 | $this->register_error($str); |
272 | - $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
|
271 | + $this->show_errors ? trigger_error($str, E_USER_WARNING) : null; |
|
273 | 272 | return false; |
274 | 273 | } |
275 | 274 | |
276 | 275 | // Query was a Data Manipulation Query (insert, delete, update, replace, ...) |
277 | - if ( !is_object($this->result) ) |
|
276 | + if ( ! is_object($this->result)) |
|
278 | 277 | { |
279 | 278 | $is_insert = true; |
280 | 279 | $this->rows_affected = @$this->dbh->affected_rows; |
281 | 280 | |
282 | 281 | // Take note of the insert_id |
283 | - if ( preg_match("/^(insert|replace)\s+/i",$query) ) |
|
282 | + if (preg_match("/^(insert|replace)\s+/i", $query)) |
|
284 | 283 | { |
285 | 284 | $this->insert_id = @$this->dbh->insert_id; |
286 | 285 | } |
@@ -294,7 +293,7 @@ discard block |
||
294 | 293 | $is_insert = false; |
295 | 294 | |
296 | 295 | // Take note of column info |
297 | - $i=0; |
|
296 | + $i = 0; |
|
298 | 297 | while ($i < @$this->result->field_count) |
299 | 298 | { |
300 | 299 | $this->col_info[$i] = @$this->result->fetch_field(); |
@@ -302,8 +301,8 @@ discard block |
||
302 | 301 | } |
303 | 302 | |
304 | 303 | // Store Query Results |
305 | - $num_rows=0; |
|
306 | - while ( $row = @$this->result->fetch_object() ) |
|
304 | + $num_rows = 0; |
|
305 | + while ($row = @$this->result->fetch_object()) |
|
307 | 306 | { |
308 | 307 | // Store relults as an objects within main array |
309 | 308 | $this->last_result[$num_rows] = $row; |
@@ -320,16 +319,16 @@ discard block |
||
320 | 319 | } |
321 | 320 | |
322 | 321 | // disk caching of queries |
323 | - $this->store_cache($query,$is_insert); |
|
322 | + $this->store_cache($query, $is_insert); |
|
324 | 323 | |
325 | 324 | // If debug ALL queries |
326 | - $this->trace || $this->debug_all ? $this->debug() : null ; |
|
325 | + $this->trace || $this->debug_all ? $this->debug() : null; |
|
327 | 326 | |
328 | 327 | // Keep tack of how long all queries have taken |
329 | 328 | $this->timer_update_global($this->num_queries); |
330 | 329 | |
331 | 330 | // Trace all queries |
332 | - if ( $this->use_trace_log ) |
|
331 | + if ($this->use_trace_log) |
|
333 | 332 | { |
334 | 333 | $this->trace_log[] = $this->debug(false); |
335 | 334 | } |
@@ -368,21 +367,21 @@ discard block |
||
368 | 367 | */ |
369 | 368 | function execute() |
370 | 369 | { |
371 | - if($this->s_query != '') |
|
370 | + if ($this->s_query != '') |
|
372 | 371 | { |
373 | 372 | $query = $this->s_query; |
374 | 373 | |
375 | - if(!empty($this->s_params)) |
|
374 | + if ( ! empty($this->s_params)) |
|
376 | 375 | { |
377 | - foreach($this->s_params as $param => $value) |
|
376 | + foreach ($this->s_params as $param => $value) |
|
378 | 377 | { |
379 | 378 | $count = 0; |
380 | 379 | $query = str_replace($param, $value, $query, $count); |
381 | - if($count == 0) |
|
380 | + if ($count == 0) |
|
382 | 381 | { |
383 | - $str = $query .' no parameter was changed'; |
|
384 | - $this->register_error($str .' in '.__FILE__.' on line '.__LINE__); |
|
385 | - $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
|
382 | + $str = $query.' no parameter was changed'; |
|
383 | + $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
|
384 | + $this->show_errors ? trigger_error($str, E_USER_WARNING) : null; |
|
386 | 385 | } |
387 | 386 | } |
388 | 387 | } |
@@ -27,8 +27,12 @@ discard block |
||
27 | 27 | * ezSQL Database specific class - mySQLi |
28 | 28 | */ |
29 | 29 | |
30 | - if ( ! function_exists ('mysqli_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
31 | - if ( ! class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
30 | + if ( ! function_exists ('mysqli_connect') ) { |
|
31 | + die('<b>Fatal Error:</b> ezSQL_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine'); |
|
32 | + } |
|
33 | + if ( ! class_exists ('ezSQLcore') ) { |
|
34 | + die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used'); |
|
35 | + } |
|
32 | 36 | |
33 | 37 | class ezSQL_mysqli extends ezSQLcore |
34 | 38 | { |
@@ -65,7 +69,9 @@ discard block |
||
65 | 69 | $return_val = false; |
66 | 70 | if ( ! $this->connect($dbuser, $dbpassword, $dbhost, $dbport) ) ; |
67 | 71 | else if ( ! $this->select($dbname,$encoding) ) ; |
68 | - else $return_val = true; |
|
72 | + else { |
|
73 | + $return_val = true; |
|
74 | + } |
|
69 | 75 | return $return_val; |
70 | 76 | } |
71 | 77 | |
@@ -100,8 +106,7 @@ discard block |
||
100 | 106 | { |
101 | 107 | $this->register_error($ezsql_mysqli_str[2].' in '.__FILE__.' on line '.__LINE__); |
102 | 108 | $this->show_errors ? trigger_error($ezsql_mysqli_str[2],E_USER_WARNING) : null; |
103 | - } |
|
104 | - else |
|
109 | + } else |
|
105 | 110 | { |
106 | 111 | $this->dbuser = $dbuser; |
107 | 112 | $this->dbpassword = $dbpassword; |
@@ -142,13 +147,13 @@ discard block |
||
142 | 147 | else if ( !@$this->dbh->select_db($dbname) ) |
143 | 148 | { |
144 | 149 | // Try to get error supplied by mysql if not use our own |
145 | - if ( !$str = @$this->dbh->error) |
|
146 | - $str = $ezsql_mysqli_str[5]; |
|
150 | + if ( !$str = @$this->dbh->error) { |
|
151 | + $str = $ezsql_mysqli_str[5]; |
|
152 | + } |
|
147 | 153 | |
148 | 154 | $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
149 | 155 | $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
150 | - } |
|
151 | - else |
|
156 | + } else |
|
152 | 157 | { |
153 | 158 | $this->dbname = $dbname; |
154 | 159 | if($encoding!='') |
@@ -258,8 +263,9 @@ discard block |
||
258 | 263 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
259 | 264 | $this->select($this->dbname,$this->encoding); |
260 | 265 | // No existing connection at this point means the server is unreachable |
261 | - if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) |
|
262 | - return false; |
|
266 | + if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) { |
|
267 | + return false; |
|
268 | + } |
|
263 | 269 | } |
264 | 270 | |
265 | 271 | // Perform the query via std mysql_query function.. |
@@ -391,8 +397,7 @@ discard block |
||
391 | 397 | $this->s_params = array(); |
392 | 398 | |
393 | 399 | return $this->query($query); |
394 | - } |
|
395 | - else |
|
400 | + } else |
|
396 | 401 | { |
397 | 402 | return NULL; |
398 | 403 | } |
@@ -34,39 +34,39 @@ discard block |
||
34 | 34 | } |
35 | 35 | public function getUserKeys() { |
36 | 36 | return array( |
37 | - 'store_url' => $this->getOption('home'), |
|
38 | - 'consumer_key' => $this->getOption('wpt_wc_api_consumer_consumer_key'), |
|
39 | - 'consumer_secret' => $this->getOption('wpt_wc_api_consumer_consumer_secret') |
|
40 | - ); |
|
37 | + 'store_url' => $this->getOption('home'), |
|
38 | + 'consumer_key' => $this->getOption('wpt_wc_api_consumer_consumer_key'), |
|
39 | + 'consumer_secret' => $this->getOption('wpt_wc_api_consumer_consumer_secret') |
|
40 | + ); |
|
41 | 41 | } |
42 | 42 | public function get($endpoint, $params) { |
43 | 43 | if ($this->synched()) { |
44 | 44 | try { |
45 | - // Array of response results. |
|
46 | - $woocommerce = $this->wc_api_connect(); |
|
47 | - $results = $woocommerce->get($endpoint, $params); |
|
48 | - // Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ... |
|
45 | + // Array of response results. |
|
46 | + $woocommerce = $this->wc_api_connect(); |
|
47 | + $results = $woocommerce->get($endpoint, $params); |
|
48 | + // Example: ['customers' => [[ 'id' => 8, 'created_at' => '2015-05-06T17:43:51Z', 'email' => ... |
|
49 | 49 | |
50 | - // Last request data. |
|
51 | - $lastRequest = $woocommerce->http->getRequest(); |
|
52 | - $lastRequest->getUrl(); // Requested URL (string). |
|
53 | - $lastRequest->getMethod(); // Request method (string). |
|
54 | - $lastRequest->getParameters(); // Request parameters (array). |
|
55 | - $lastRequest->getHeaders(); // Request headers (array). |
|
56 | - $lastRequest->getBody(); // Request body (JSON). |
|
50 | + // Last request data. |
|
51 | + $lastRequest = $woocommerce->http->getRequest(); |
|
52 | + $lastRequest->getUrl(); // Requested URL (string). |
|
53 | + $lastRequest->getMethod(); // Request method (string). |
|
54 | + $lastRequest->getParameters(); // Request parameters (array). |
|
55 | + $lastRequest->getHeaders(); // Request headers (array). |
|
56 | + $lastRequest->getBody(); // Request body (JSON). |
|
57 | 57 | |
58 | - // Last response data. |
|
59 | - $lastResponse = $woocommerce->http->getResponse(); |
|
60 | - $lastResponse->getCode(); // Response code (int). |
|
61 | - $lastResponse->getHeaders(); // Response headers (array). |
|
62 | - $lastResponse->getBody(); // Response body (JSON). |
|
58 | + // Last response data. |
|
59 | + $lastResponse = $woocommerce->http->getResponse(); |
|
60 | + $lastResponse->getCode(); // Response code (int). |
|
61 | + $lastResponse->getHeaders(); // Response headers (array). |
|
62 | + $lastResponse->getBody(); // Response body (JSON). |
|
63 | 63 | |
64 | - return $results; |
|
64 | + return $results; |
|
65 | 65 | |
66 | 66 | } catch (HttpClientException $e) { |
67 | - $e->getMessage(); // Error message. |
|
68 | - $e->getRequest(); // Last request data. |
|
69 | - $e->getResponse(); // Last response data. |
|
67 | + $e->getMessage(); // Error message. |
|
68 | + $e->getRequest(); // Last request data. |
|
69 | + $e->getResponse(); // Last response data. |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | * @return \Automattic\WooCommerce\Client|bool |
132 | 132 | */ |
133 | 133 | public function wc_api_connect() { |
134 | - static $connection; |
|
134 | + static $connection; |
|
135 | 135 | |
136 | - if ( isset( $connection ) ) { |
|
137 | - return $connection; |
|
138 | - } |
|
136 | + if ( isset( $connection ) ) { |
|
137 | + return $connection; |
|
138 | + } |
|
139 | 139 | |
140 | - $keys = $this->getUserKeys(); |
|
140 | + $keys = $this->getUserKeys(); |
|
141 | 141 | |
142 | - if ( ! $keys ) { |
|
143 | - $connection = false; |
|
142 | + if ( ! $keys ) { |
|
143 | + $connection = false; |
|
144 | 144 | |
145 | - return $connection; |
|
146 | - } |
|
145 | + return $connection; |
|
146 | + } |
|
147 | 147 | |
148 | - $connection = new Client( |
|
149 | - $keys['store_url'], |
|
150 | - $keys['consumer_key'], |
|
151 | - $keys['consumer_secret'], |
|
152 | - array( |
|
153 | - 'wp_api' => true, |
|
154 | - 'version' => 'wc/v2', |
|
155 | - 'verify_ssl' => false, // Allow self-signed certificates (remove for prod) |
|
156 | - ) |
|
157 | - ); |
|
148 | + $connection = new Client( |
|
149 | + $keys['store_url'], |
|
150 | + $keys['consumer_key'], |
|
151 | + $keys['consumer_secret'], |
|
152 | + array( |
|
153 | + 'wp_api' => true, |
|
154 | + 'version' => 'wc/v2', |
|
155 | + 'verify_ssl' => false, // Allow self-signed certificates (remove for prod) |
|
156 | + ) |
|
157 | + ); |
|
158 | 158 | |
159 | - return $connection; |
|
159 | + return $connection; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 |
@@ -133,13 +133,13 @@ |
||
133 | 133 | public function wc_api_connect() { |
134 | 134 | static $connection; |
135 | 135 | |
136 | - if ( isset( $connection ) ) { |
|
136 | + if (isset($connection)) { |
|
137 | 137 | return $connection; |
138 | 138 | } |
139 | 139 | |
140 | 140 | $keys = $this->getUserKeys(); |
141 | 141 | |
142 | - if ( ! $keys ) { |
|
142 | + if ( ! $keys) { |
|
143 | 143 | $connection = false; |
144 | 144 | |
145 | 145 | return $connection; |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $fn = new Functions(); |
43 | 43 | return $fn->generateRepairReference(); |
44 | 44 | } |
45 | - public static function implodeAddress($id=null, $context) { |
|
45 | + public static function implodeAddress($id = null, $context) { |
|
46 | 46 | $fn = new Functions(); |
47 | 47 | return $fn->implodeAddress($id, $context); |
48 | 48 | } |
@@ -129,13 +129,13 @@ |
||
129 | 129 | return 'REPAIR-'.date('ymd').'-'.strtoupper($this->generateRandomString()); |
130 | 130 | } |
131 | 131 | public function generateRandomString($length = 5) { |
132 | - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
|
133 | - $charactersLength = strlen($characters); |
|
134 | - $randomString = ''; |
|
135 | - for ($i = 0; $i < $length; $i++) { |
|
136 | - $randomString .= $characters[rand(0, $charactersLength - 1)]; |
|
137 | - } |
|
138 | - return $randomString; |
|
132 | + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
|
133 | + $charactersLength = strlen($characters); |
|
134 | + $randomString = ''; |
|
135 | + for ($i = 0; $i < $length; $i++) { |
|
136 | + $randomString .= $characters[rand(0, $charactersLength - 1)]; |
|
137 | + } |
|
138 | + return $randomString; |
|
139 | 139 | } |
140 | 140 | public function getTicketIssueTypes($id = null) { |
141 | 141 | if ( ! $id) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($appointment->appointment_datetime) { |
194 | 194 | array_push($list, array( |
195 | 195 | 'id' => $appointment->id, |
196 | - 'title' => $appointment->ticket_reference . ' ( '.$appointment->appointment_datetime.' ) ', |
|
196 | + 'title' => $appointment->ticket_reference.' ( '.$appointment->appointment_datetime.' ) ', |
|
197 | 197 | 'start' => $appointment->appointment_datetime, |
198 | 198 | )); |
199 | 199 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | public function getRepairStatuses($id = null, $str = false) { |
216 | - $statuses = array( |
|
216 | + $statuses = array( |
|
217 | 217 | '1' => __('label_new'), |
218 | 218 | '2' => __('label_progress'), |
219 | 219 | '3' => __('label_resolved'), |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | '8' => __('label_customer_reply') |
225 | 225 | ); |
226 | 226 | |
227 | - if ( !$id && ! $str) { |
|
227 | + if ( ! $id && ! $str) { |
|
228 | 228 | return $statuses; |
229 | 229 | } else { |
230 | 230 | return $statuses[$id]; |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | public function getAppointmentTypes($id = null, $str = false) { |
235 | - if ( !$id ) { |
|
236 | - $id = 1; |
|
235 | + if ( ! $id) { |
|
236 | + $id = 1; |
|
237 | 237 | } |
238 | 238 | $types = array( |
239 | 239 | '1' => array('id' => 1, 'value' => __('label_in_shop')), |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | '3' => array('id' => 3, 'value' => __('label_phone_call')), |
242 | 242 | ); |
243 | 243 | |
244 | - if ( !$id && ! $str) { |
|
244 | + if ( ! $id && ! $str) { |
|
245 | 245 | return $types; |
246 | 246 | } else { |
247 | 247 | return $types[$id]['value']; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | return []; |
292 | 292 | } |
293 | 293 | |
294 | - public function implodeAddress($id=null, $context) { |
|
294 | + public function implodeAddress($id = null, $context) { |
|
295 | 295 | |
296 | 296 | switch ($context) { |
297 | 297 | case 'client': |
@@ -25,11 +25,11 @@ |
||
25 | 25 | */ |
26 | 26 | interface LoggerAwareInterface |
27 | 27 | { |
28 | - /** |
|
29 | - * Sets a logger instance on the object |
|
30 | - * |
|
31 | - * @param LoggerInterface $logger |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function setLogger(LoggerInterface $logger); |
|
28 | + /** |
|
29 | + * Sets a logger instance on the object |
|
30 | + * |
|
31 | + * @param LoggerInterface $logger |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function setLogger(LoggerInterface $logger); |
|
35 | 35 | } |
36 | 36 | \ No newline at end of file |
@@ -22,96 +22,96 @@ |
||
22 | 22 | |
23 | 23 | interface LoggerInterface |
24 | 24 | { |
25 | - /** |
|
26 | - * System is unusable. |
|
27 | - * |
|
28 | - * @param string $message |
|
29 | - * @param array $context |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public function emergency($message, array $context = array()); |
|
25 | + /** |
|
26 | + * System is unusable. |
|
27 | + * |
|
28 | + * @param string $message |
|
29 | + * @param array $context |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public function emergency($message, array $context = array()); |
|
33 | 33 | |
34 | - /** |
|
35 | - * Action must be taken immediately. |
|
36 | - * |
|
37 | - * Example: Entire website down, database unavailable, etc. This should |
|
38 | - * trigger the SMS alerts and wake you up. |
|
39 | - * |
|
40 | - * @param string $message |
|
41 | - * @param array $context |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function alert($message, array $context = array()); |
|
34 | + /** |
|
35 | + * Action must be taken immediately. |
|
36 | + * |
|
37 | + * Example: Entire website down, database unavailable, etc. This should |
|
38 | + * trigger the SMS alerts and wake you up. |
|
39 | + * |
|
40 | + * @param string $message |
|
41 | + * @param array $context |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function alert($message, array $context = array()); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Critical conditions. |
|
48 | - * |
|
49 | - * Example: Application component unavailable, unexpected exception. |
|
50 | - * |
|
51 | - * @param string $message |
|
52 | - * @param array $context |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function critical($message, array $context = array()); |
|
46 | + /** |
|
47 | + * Critical conditions. |
|
48 | + * |
|
49 | + * Example: Application component unavailable, unexpected exception. |
|
50 | + * |
|
51 | + * @param string $message |
|
52 | + * @param array $context |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function critical($message, array $context = array()); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Runtime errors that do not require immediate action but should typically |
|
59 | - * be logged and monitored. |
|
60 | - * |
|
61 | - * @param string $message |
|
62 | - * @param array $context |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function error($message, array $context = array()); |
|
57 | + /** |
|
58 | + * Runtime errors that do not require immediate action but should typically |
|
59 | + * be logged and monitored. |
|
60 | + * |
|
61 | + * @param string $message |
|
62 | + * @param array $context |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function error($message, array $context = array()); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Exceptional occurrences that are not errors. |
|
69 | - * |
|
70 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
71 | - * that are not necessarily wrong. |
|
72 | - * |
|
73 | - * @param string $message |
|
74 | - * @param array $context |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public function warning($message, array $context = array()); |
|
67 | + /** |
|
68 | + * Exceptional occurrences that are not errors. |
|
69 | + * |
|
70 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
71 | + * that are not necessarily wrong. |
|
72 | + * |
|
73 | + * @param string $message |
|
74 | + * @param array $context |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public function warning($message, array $context = array()); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Normal but significant events. |
|
81 | - * |
|
82 | - * @param string $message |
|
83 | - * @param array $context |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function notice($message, array $context = array()); |
|
79 | + /** |
|
80 | + * Normal but significant events. |
|
81 | + * |
|
82 | + * @param string $message |
|
83 | + * @param array $context |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function notice($message, array $context = array()); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Interesting events. |
|
90 | - * |
|
91 | - * Example: User logs in, SQL logs. |
|
92 | - * |
|
93 | - * @param string $message |
|
94 | - * @param array $context |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - public function info($message, array $context = array()); |
|
88 | + /** |
|
89 | + * Interesting events. |
|
90 | + * |
|
91 | + * Example: User logs in, SQL logs. |
|
92 | + * |
|
93 | + * @param string $message |
|
94 | + * @param array $context |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + public function info($message, array $context = array()); |
|
98 | 98 | |
99 | - /** |
|
100 | - * Detailed debug information. |
|
101 | - * |
|
102 | - * @param string $message |
|
103 | - * @param array $context |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function debug($message, array $context = array()); |
|
99 | + /** |
|
100 | + * Detailed debug information. |
|
101 | + * |
|
102 | + * @param string $message |
|
103 | + * @param array $context |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function debug($message, array $context = array()); |
|
107 | 107 | |
108 | - /** |
|
109 | - * Logs with an arbitrary level. |
|
110 | - * |
|
111 | - * @param mixed $level |
|
112 | - * @param string $message |
|
113 | - * @param array $context |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - public function log($level, $message, array $context = array()); |
|
108 | + /** |
|
109 | + * Logs with an arbitrary level. |
|
110 | + * |
|
111 | + * @param mixed $level |
|
112 | + * @param string $message |
|
113 | + * @param array $context |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + public function log($level, $message, array $context = array()); |
|
117 | 117 | } |
118 | 118 | \ No newline at end of file |
@@ -22,111 +22,111 @@ |
||
22 | 22 | |
23 | 23 | interface CacheInterface |
24 | 24 | { |
25 | - /** |
|
26 | - * Fetches a value from the cache. |
|
27 | - * |
|
28 | - * @param string $key The unique key of this item in the cache. |
|
29 | - * @param mixed $default Default value to return if the key does not exist. |
|
30 | - * |
|
31 | - * @return mixed The value of the item from the cache, or $default in case of cache miss. |
|
32 | - * |
|
33 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
34 | - * MUST be thrown if the $key string is not a legal value. |
|
35 | - */ |
|
36 | - public function get($key, $default = null); |
|
25 | + /** |
|
26 | + * Fetches a value from the cache. |
|
27 | + * |
|
28 | + * @param string $key The unique key of this item in the cache. |
|
29 | + * @param mixed $default Default value to return if the key does not exist. |
|
30 | + * |
|
31 | + * @return mixed The value of the item from the cache, or $default in case of cache miss. |
|
32 | + * |
|
33 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
34 | + * MUST be thrown if the $key string is not a legal value. |
|
35 | + */ |
|
36 | + public function get($key, $default = null); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
|
40 | - * |
|
41 | - * @param string $key The key of the item to store. |
|
42 | - * @param mixed $value The value of the item to store, must be serializable. |
|
43 | - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
|
44 | - * the driver supports TTL then the library may set a default value |
|
45 | - * for it or let the driver take care of that. |
|
46 | - * |
|
47 | - * @return bool True on success and false on failure. |
|
48 | - * |
|
49 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
50 | - * MUST be thrown if the $key string is not a legal value. |
|
51 | - */ |
|
52 | - public function set($key, $value, $ttl = null); |
|
38 | + /** |
|
39 | + * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
|
40 | + * |
|
41 | + * @param string $key The key of the item to store. |
|
42 | + * @param mixed $value The value of the item to store, must be serializable. |
|
43 | + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
|
44 | + * the driver supports TTL then the library may set a default value |
|
45 | + * for it or let the driver take care of that. |
|
46 | + * |
|
47 | + * @return bool True on success and false on failure. |
|
48 | + * |
|
49 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
50 | + * MUST be thrown if the $key string is not a legal value. |
|
51 | + */ |
|
52 | + public function set($key, $value, $ttl = null); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Delete an item from the cache by its unique key. |
|
56 | - * |
|
57 | - * @param string $key The unique cache key of the item to delete. |
|
58 | - * |
|
59 | - * @return bool True if the item was successfully removed. False if there was an error. |
|
60 | - * |
|
61 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
62 | - * MUST be thrown if the $key string is not a legal value. |
|
63 | - */ |
|
64 | - public function delete($key); |
|
54 | + /** |
|
55 | + * Delete an item from the cache by its unique key. |
|
56 | + * |
|
57 | + * @param string $key The unique cache key of the item to delete. |
|
58 | + * |
|
59 | + * @return bool True if the item was successfully removed. False if there was an error. |
|
60 | + * |
|
61 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
62 | + * MUST be thrown if the $key string is not a legal value. |
|
63 | + */ |
|
64 | + public function delete($key); |
|
65 | 65 | |
66 | - /** |
|
67 | - * Wipes clean the entire cache's keys. |
|
68 | - * |
|
69 | - * @return bool True on success and false on failure. |
|
70 | - */ |
|
71 | - public function clear(); |
|
66 | + /** |
|
67 | + * Wipes clean the entire cache's keys. |
|
68 | + * |
|
69 | + * @return bool True on success and false on failure. |
|
70 | + */ |
|
71 | + public function clear(); |
|
72 | 72 | |
73 | - /** |
|
74 | - * Obtains multiple cache items by their unique keys. |
|
75 | - * |
|
76 | - * @param iterable $keys A list of keys that can obtained in a single operation. |
|
77 | - * @param mixed $default Default value to return for keys that do not exist. |
|
78 | - * |
|
79 | - * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. |
|
80 | - * |
|
81 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
82 | - * MUST be thrown if $keys is neither an array nor a Traversable, |
|
83 | - * or if any of the $keys are not a legal value. |
|
84 | - */ |
|
85 | - public function getMultiple($keys, $default = null); |
|
73 | + /** |
|
74 | + * Obtains multiple cache items by their unique keys. |
|
75 | + * |
|
76 | + * @param iterable $keys A list of keys that can obtained in a single operation. |
|
77 | + * @param mixed $default Default value to return for keys that do not exist. |
|
78 | + * |
|
79 | + * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. |
|
80 | + * |
|
81 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
82 | + * MUST be thrown if $keys is neither an array nor a Traversable, |
|
83 | + * or if any of the $keys are not a legal value. |
|
84 | + */ |
|
85 | + public function getMultiple($keys, $default = null); |
|
86 | 86 | |
87 | - /** |
|
88 | - * Persists a set of key => value pairs in the cache, with an optional TTL. |
|
89 | - * |
|
90 | - * @param iterable $values A list of key => value pairs for a multiple-set operation. |
|
91 | - * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
|
92 | - * the driver supports TTL then the library may set a default value |
|
93 | - * for it or let the driver take care of that. |
|
94 | - * |
|
95 | - * @return bool True on success and false on failure. |
|
96 | - * |
|
97 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
98 | - * MUST be thrown if $values is neither an array nor a Traversable, |
|
99 | - * or if any of the $values are not a legal value. |
|
100 | - */ |
|
101 | - public function setMultiple($values, $ttl = null); |
|
87 | + /** |
|
88 | + * Persists a set of key => value pairs in the cache, with an optional TTL. |
|
89 | + * |
|
90 | + * @param iterable $values A list of key => value pairs for a multiple-set operation. |
|
91 | + * @param null|int|\DateInterval $ttl Optional. The TTL value of this item. If no value is sent and |
|
92 | + * the driver supports TTL then the library may set a default value |
|
93 | + * for it or let the driver take care of that. |
|
94 | + * |
|
95 | + * @return bool True on success and false on failure. |
|
96 | + * |
|
97 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
98 | + * MUST be thrown if $values is neither an array nor a Traversable, |
|
99 | + * or if any of the $values are not a legal value. |
|
100 | + */ |
|
101 | + public function setMultiple($values, $ttl = null); |
|
102 | 102 | |
103 | - /** |
|
104 | - * Deletes multiple cache items in a single operation. |
|
105 | - * |
|
106 | - * @param iterable $keys A list of string-based keys to be deleted. |
|
107 | - * |
|
108 | - * @return bool True if the items were successfully removed. False if there was an error. |
|
109 | - * |
|
110 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
111 | - * MUST be thrown if $keys is neither an array nor a Traversable, |
|
112 | - * or if any of the $keys are not a legal value. |
|
113 | - */ |
|
114 | - public function deleteMultiple($keys); |
|
103 | + /** |
|
104 | + * Deletes multiple cache items in a single operation. |
|
105 | + * |
|
106 | + * @param iterable $keys A list of string-based keys to be deleted. |
|
107 | + * |
|
108 | + * @return bool True if the items were successfully removed. False if there was an error. |
|
109 | + * |
|
110 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
111 | + * MUST be thrown if $keys is neither an array nor a Traversable, |
|
112 | + * or if any of the $keys are not a legal value. |
|
113 | + */ |
|
114 | + public function deleteMultiple($keys); |
|
115 | 115 | |
116 | - /** |
|
117 | - * Determines whether an item is present in the cache. |
|
118 | - * |
|
119 | - * NOTE: It is recommended that has() is only to be used for cache warming type purposes |
|
120 | - * and not to be used within your live applications operations for get/set, as this method |
|
121 | - * is subject to a race condition where your has() will return true and immediately after, |
|
122 | - * another script can remove it making the state of your app out of date. |
|
123 | - * |
|
124 | - * @param string $key The cache item key. |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - * |
|
128 | - * @throws \Mmanager\Exception\InvalidArgumentException |
|
129 | - * MUST be thrown if the $key string is not a legal value. |
|
130 | - */ |
|
131 | - public function has($key); |
|
116 | + /** |
|
117 | + * Determines whether an item is present in the cache. |
|
118 | + * |
|
119 | + * NOTE: It is recommended that has() is only to be used for cache warming type purposes |
|
120 | + * and not to be used within your live applications operations for get/set, as this method |
|
121 | + * is subject to a race condition where your has() will return true and immediately after, |
|
122 | + * another script can remove it making the state of your app out of date. |
|
123 | + * |
|
124 | + * @param string $key The cache item key. |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + * |
|
128 | + * @throws \Mmanager\Exception\InvalidArgumentException |
|
129 | + * MUST be thrown if the $key string is not a legal value. |
|
130 | + */ |
|
131 | + public function has($key); |
|
132 | 132 | } |
133 | 133 | \ No newline at end of file |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | foreach ($orders as &$order) { |
104 | 104 | if ($order->amount_paid > 0 AND $order->order_status == 'Refunded') |
105 | 105 | { |
106 | - $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix') . sprintf( "%04s", $order->order_number ) : get_option('credit_note_prefix') . sprintf( "%04s", $order->order_number ); |
|
106 | + $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix').sprintf("%04s", $order->order_number) : get_option('credit_note_prefix').sprintf("%04s", $order->order_number); |
|
107 | 107 | } |
108 | 108 | elseif ($order->order_status == 'Refunded') |
109 | 109 | { |
110 | - $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix') . sprintf( "%04s", $order->order_number ) : get_option('credit_note_prefix') . sprintf( "%04s", $order->order_number ); |
|
110 | + $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix').sprintf("%04s", $order->order_number) : get_option('credit_note_prefix').sprintf("%04s", $order->order_number); |
|
111 | 111 | } |
112 | 112 | elseif ($order->amount_paid > 0 AND $order->amount_due > 0 AND $order->order_status !== 'Paid') |
113 | 113 | { |
114 | - $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
|
114 | + $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short').sprintf("%04s", $order->order_number) : get_option('sale_order_prefix').sprintf("%04s", $order->order_number); |
|
115 | 115 | } |
116 | - elseif( $order->order_status == 'Expired' || $order->order_status == 'Open' || $order->order_status == 'Pending' || $order->order_status == 'Failed') |
|
116 | + elseif ($order->order_status == 'Expired' || $order->order_status == 'Open' || $order->order_status == 'Pending' || $order->order_status == 'Failed') |
|
117 | 117 | { |
118 | - $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
|
118 | + $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short').sprintf("%04s", $order->order_number) : get_option('sale_order_prefix').sprintf("%04s", $order->order_number); |
|
119 | 119 | } |
120 | 120 | else |
121 | 121 | { |
122 | - $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
|
122 | + $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short').sprintf("%04s", $order->order_number) : get_option('sale_order_prefix').sprintf("%04s", $order->order_number); |
|
123 | 123 | } |
124 | 124 | array_push($this->list, array( |
125 | 125 | 'id' => $order->id, |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | 'number_prefix' => $number_prefix, |
128 | 128 | 'order_number' => $order->order_number, |
129 | 129 | 'enc_order_number' => _eID($order->order_number), |
130 | - 'name_company' => $invoiceObj->getCustomer($order->client_id,'name_company'), |
|
131 | - 'date' => _fdate( language_string_to_locale_notation( get_option('user_language', 'users_options') ), $order->date ), |
|
132 | - 'due_date' => _fdate( language_string_to_locale_notation( get_option('user_language', 'users_options') ), $order->due_date ), |
|
130 | + 'name_company' => $invoiceObj->getCustomer($order->client_id, 'name_company'), |
|
131 | + 'date' => _fdate(language_string_to_locale_notation(get_option('user_language', 'users_options')), $order->date), |
|
132 | + 'due_date' => _fdate(language_string_to_locale_notation(get_option('user_language', 'users_options')), $order->due_date), |
|
133 | 133 | 'total' => format_number($order->total), |
134 | 134 | 'amount_due' => format_number($order->amount_due), |
135 | 135 | 'amount_paid' => format_number($order->amount_paid), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | foreach ($clients as &$client) { |
156 | 156 | if (isset($client->client_address1) && $client->client_postcode && $client->client_city && $client->client_country) |
157 | 157 | { |
158 | - $address = $client->client_address1 . ' ' . $client->client_postcode . ' ' . $client->client_city . ' ' . get_countries($client->client_country); |
|
158 | + $address = $client->client_address1.' '.$client->client_postcode.' '.$client->client_city.' '.get_countries($client->client_country); |
|
159 | 159 | } |
160 | 160 | else |
161 | 161 | { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'client_tax_number' => isset($client->client_tax_number) ? $client->client_tax_number : "", |
175 | 175 | 'client_bank_number' => isset($client->client_bank_number) ? $client->client_bank_number : "", |
176 | 176 | 'client_status_str' => status_str($client->client_status), |
177 | - 'client_date_created' => _fdate( language_string_to_locale_notation( get_option('user_language', 'users_options') ), $client->client_date_created) |
|
177 | + 'client_date_created' => _fdate(language_string_to_locale_notation(get_option('user_language', 'users_options')), $client->client_date_created) |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'qrcode' => $item->qrcode, |
208 | 208 | 'barcode' => $item->barcode, |
209 | 209 | 'hasqrbar' => $hasqrbar, |
210 | - 'item_status_str' => '0.00' !== $item->current_stock ? $item->current_stock .' ' .item_status_str($item->item_status) : '' .' ' .item_status_str($item->item_status) |
|
210 | + 'item_status_str' => '0.00' !== $item->current_stock ? $item->current_stock.' '.item_status_str($item->item_status) : ''.' '.item_status_str($item->item_status) |
|
211 | 211 | ) |
212 | 212 | ); |
213 | 213 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | 'price' =>format_number($item->price), |
235 | 235 | 'tax_percent' => $item->tax_percent, |
236 | 236 | 'item_status' => $item->item_status, |
237 | - 'item_status_str' => '0.00' !== $item->current_stock ? $item->current_stock .' ' .item_status_str($item->item_status) : '' .' ' .item_status_str($item->item_status) |
|
237 | + 'item_status_str' => '0.00' !== $item->current_stock ? $item->current_stock.' '.item_status_str($item->item_status) : ''.' '.item_status_str($item->item_status) |
|
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | } |
@@ -104,20 +104,16 @@ discard block |
||
104 | 104 | if ($order->amount_paid > 0 AND $order->order_status == 'Refunded') |
105 | 105 | { |
106 | 106 | $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix') . sprintf( "%04s", $order->order_number ) : get_option('credit_note_prefix') . sprintf( "%04s", $order->order_number ); |
107 | - } |
|
108 | - elseif ($order->order_status == 'Refunded') |
|
107 | + } elseif ($order->order_status == 'Refunded') |
|
109 | 108 | { |
110 | 109 | $number_prefix = null == get_option('credit_note_prefix') ? __('credit_note_prefix') . sprintf( "%04s", $order->order_number ) : get_option('credit_note_prefix') . sprintf( "%04s", $order->order_number ); |
111 | - } |
|
112 | - elseif ($order->amount_paid > 0 AND $order->amount_due > 0 AND $order->order_status !== 'Paid') |
|
110 | + } elseif ($order->amount_paid > 0 AND $order->amount_due > 0 AND $order->order_status !== 'Paid') |
|
113 | 111 | { |
114 | 112 | $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
115 | - } |
|
116 | - elseif( $order->order_status == 'Expired' || $order->order_status == 'Open' || $order->order_status == 'Pending' || $order->order_status == 'Failed') |
|
113 | + } elseif( $order->order_status == 'Expired' || $order->order_status == 'Open' || $order->order_status == 'Pending' || $order->order_status == 'Failed') |
|
117 | 114 | { |
118 | 115 | $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
119 | - } |
|
120 | - else |
|
116 | + } else |
|
121 | 117 | { |
122 | 118 | $number_prefix = null == get_option('sale_order_prefix') ? __('sale_order_prefix_short') . sprintf( "%04s", $order->order_number ) : get_option('sale_order_prefix') . sprintf( "%04s", $order->order_number ); |
123 | 119 | } |
@@ -156,8 +152,7 @@ discard block |
||
156 | 152 | if (isset($client->client_address1) && $client->client_postcode && $client->client_city && $client->client_country) |
157 | 153 | { |
158 | 154 | $address = $client->client_address1 . ' ' . $client->client_postcode . ' ' . $client->client_city . ' ' . get_countries($client->client_country); |
159 | - } |
|
160 | - else |
|
155 | + } else |
|
161 | 156 | { |
162 | 157 | $address = false; |
163 | 158 | } |