@@ -68,6 +68,9 @@ discard block |
||
68 | 68 | * Returns array of host and port. If port is omitted, returns $default |
69 | 69 | */ |
70 | 70 | |
71 | + /** |
|
72 | + * @param string $host |
|
73 | + */ |
|
71 | 74 | function get_host_port( $host, $default = false ) |
72 | 75 | { |
73 | 76 | $port = $default; |
@@ -218,6 +221,9 @@ discard block |
||
218 | 221 | * Return the the query as a result set - see docs for more details |
219 | 222 | */ |
220 | 223 | |
224 | + /** |
|
225 | + * @param string $output |
|
226 | + */ |
|
221 | 227 | function get_results($query=null, $output = OBJECT) |
222 | 228 | { |
223 | 229 | |
@@ -296,6 +302,10 @@ discard block |
||
296 | 302 | * store_cache |
297 | 303 | */ |
298 | 304 | |
305 | + /** |
|
306 | + * @param string $query |
|
307 | + * @param boolean $is_insert |
|
308 | + */ |
|
299 | 309 | function store_cache($query,$is_insert) |
300 | 310 | { |
301 | 311 | |
@@ -332,6 +342,9 @@ discard block |
||
332 | 342 | * get_cache |
333 | 343 | */ |
334 | 344 | |
345 | + /** |
|
346 | + * @param string $query |
|
347 | + */ |
|
335 | 348 | function get_cache($query) |
336 | 349 | { |
337 | 350 | |
@@ -561,6 +574,9 @@ discard block |
||
561 | 574 | return round($this->timer_get_cur() - $this->timers[$timer_name],2); |
562 | 575 | } |
563 | 576 | |
577 | + /** |
|
578 | + * @param integer $timer_name |
|
579 | + */ |
|
564 | 580 | function timer_update_global($timer_name) |
565 | 581 | { |
566 | 582 | if ( $this->do_profile ) |
@@ -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,7 +463,7 @@ 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}"; |
@@ -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()' : |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | echo "</pre>"; |
8 | 8 | } |
9 | 9 | |
10 | -function returnSectorGas($arr,$sector,$gas) |
|
10 | +function returnSectorGas($arr, $sector, $gas) |
|
11 | 11 | { |
12 | 12 | |
13 | - foreach($arr as $val) |
|
13 | + foreach ($arr as $val) |
|
14 | 14 | { |
15 | - if($val['sector'] == $sector && $val['gas'] == $gas) |
|
15 | + if ($val['sector'] == $sector && $val['gas'] == $gas) |
|
16 | 16 | { |
17 | 17 | return $val['total']; |
18 | 18 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | return 0; |
22 | 22 | } |
23 | 23 | |
24 | -function returnSectorAno($arr,$sector,$ano) |
|
24 | +function returnSectorAno($arr, $sector, $ano) |
|
25 | 25 | { |
26 | 26 | |
27 | - foreach($arr as $val) |
|
27 | + foreach ($arr as $val) |
|
28 | 28 | { |
29 | - if($val['sector'] == $sector && $val['ano'] == $ano) |
|
29 | + if ($val['sector'] == $sector && $val['ano'] == $ano) |
|
30 | 30 | { |
31 | 31 | return $val['total']; |
32 | 32 | } |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | return 0; |
36 | 36 | } |
37 | 37 | |
38 | -function returnSubactividadAno($arr,$subactividad,$ano) |
|
38 | +function returnSubactividadAno($arr, $subactividad, $ano) |
|
39 | 39 | { |
40 | 40 | |
41 | - foreach($arr as $val) |
|
41 | + foreach ($arr as $val) |
|
42 | 42 | { |
43 | - if(trim($val['nombre']) == trim($subactividad) && $val['ano'] == $ano) |
|
43 | + if (trim($val['nombre']) == trim($subactividad) && $val['ano'] == $ano) |
|
44 | 44 | { |
45 | 45 | return $val['valor']; |
46 | 46 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | return 0; |
50 | 50 | } |
51 | 51 | |
52 | -function returnCategoriaAno($arr,$categoria,$ano) |
|
52 | +function returnCategoriaAno($arr, $categoria, $ano) |
|
53 | 53 | { |
54 | 54 | |
55 | - foreach($arr as $val) |
|
55 | + foreach ($arr as $val) |
|
56 | 56 | { |
57 | - if(trim($val['nombre']) == trim($categoria) && $val['ano'] == $ano) |
|
57 | + if (trim($val['nombre']) == trim($categoria) && $val['ano'] == $ano) |
|
58 | 58 | { |
59 | 59 | return $val['valor']; |
60 | 60 | } |
@@ -2,28 +2,28 @@ |
||
2 | 2 | |
3 | 3 | if ($_SERVER['HTTP_HOST'] == 'chali.thet.com.ar') { |
4 | 4 | |
5 | - define("DB_USER" , "root"); // <-- mysql db user |
|
6 | - define("DB_PASSWORD" , "root"); // <-- mysql db password |
|
7 | - define("DB_NAME" , "min_ambiente"); // <-- mysql db pname |
|
8 | - define("DB_HOST" , "127.0.0.1"); // <-- mysql server host |
|
5 | + define("DB_USER", "root"); // <-- mysql db user |
|
6 | + define("DB_PASSWORD", "root"); // <-- mysql db password |
|
7 | + define("DB_NAME", "min_ambiente"); // <-- mysql db pname |
|
8 | + define("DB_HOST", "127.0.0.1"); // <-- mysql server host |
|
9 | 9 | |
10 | 10 | } |
11 | 11 | |
12 | 12 | if ($_SERVER['HTTP_HOST'] == 'thet.com.ar') { |
13 | 13 | |
14 | - define("DB_USER" , "thet_minamb"); // <-- mysql db user |
|
15 | - define("DB_PASSWORD" , "VeDwOtr3ChPF"); // <-- mysql db password |
|
16 | - define("DB_NAME" , "thet_minamb"); // <-- mysql db pname |
|
17 | - define("DB_HOST" , "localhost"); // <-- mysql server host |
|
14 | + define("DB_USER", "thet_minamb"); // <-- mysql db user |
|
15 | + define("DB_PASSWORD", "VeDwOtr3ChPF"); // <-- mysql db password |
|
16 | + define("DB_NAME", "thet_minamb"); // <-- mysql db pname |
|
17 | + define("DB_HOST", "localhost"); // <-- mysql server host |
|
18 | 18 | |
19 | 19 | } |
20 | 20 | |
21 | 21 | if ($_SERVER['HTTP_HOST'] == 'vminventariogei-test.medioambiente.gov.ar') { |
22 | 22 | |
23 | - define("DB_USER" , "ibegtest"); // <-- mysql db user |
|
24 | - define("DB_PASSWORD" , "aTDjmJcDC4LFZK9R"); // <-- mysql db password |
|
25 | - define("DB_NAME" , "ibegtest"); // <-- mysql db pname |
|
26 | - define("DB_HOST" , "localhost"); // <-- mysql server host |
|
23 | + define("DB_USER", "ibegtest"); // <-- mysql db user |
|
24 | + define("DB_PASSWORD", "aTDjmJcDC4LFZK9R"); // <-- mysql db password |
|
25 | + define("DB_NAME", "ibegtest"); // <-- mysql db pname |
|
26 | + define("DB_HOST", "localhost"); // <-- mysql server host |
|
27 | 27 | |
28 | 28 | } |
29 | 29 |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | include "init.php"; |
6 | 6 | |
7 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'run' ) |
|
7 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'run') |
|
8 | 8 | { |
9 | 9 | |
10 | 10 | } |
11 | 11 | |
12 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-sector' && !empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] == 'all') |
|
12 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-sector' && !empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] == 'all') |
|
13 | 13 | { |
14 | - $ano = (int)$_REQUEST['ano']; |
|
14 | + $ano = (int) $_REQUEST['ano']; |
|
15 | 15 | |
16 | 16 | $arrReturn = array(); |
17 | 17 | |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | WHERE e.ano = $ano |
22 | 22 | GROUP BY e.sector_id"; |
23 | 23 | |
24 | - $arr = $db->get_results($sql,ARRAY_A); |
|
24 | + $arr = $db->get_results($sql, ARRAY_A); |
|
25 | 25 | |
26 | 26 | $i = 1; |
27 | 27 | |
28 | - foreach($arr as $a) |
|
28 | + foreach ($arr as $a) |
|
29 | 29 | { |
30 | 30 | $arrReturn['sector_'.$i][] = $a['nombre']; |
31 | 31 | $arrReturn['sector_'.$i][] = $a['total']; |
32 | - $arrReturn['colores'][] = $a['color']; |
|
33 | - $arrReturn['descripciones'][] = $a['descripcion']; |
|
32 | + $arrReturn['colores'][] = $a['color']; |
|
33 | + $arrReturn['descripciones'][] = $a['descripcion']; |
|
34 | 34 | |
35 | 35 | $i++; |
36 | 36 | } |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 46 | |
47 | 47 | |
48 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-sector' && !empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') |
|
48 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-sector' && !empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') |
|
49 | 49 | { |
50 | - $ano = (int)$_REQUEST['ano']; |
|
51 | - $sector_id = (int)$_REQUEST['sector_id']; |
|
50 | + $ano = (int) $_REQUEST['ano']; |
|
51 | + $sector_id = (int) $_REQUEST['sector_id']; |
|
52 | 52 | |
53 | 53 | $sql = "SELECT SUM(e.valor) as total, a.id, a.nombre |
54 | 54 | FROM emision e |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | GROUP BY a.id |
61 | 61 | ORDER BY a.nombre"; |
62 | 62 | |
63 | - $arr = $db->get_results($sql,ARRAY_A); |
|
63 | + $arr = $db->get_results($sql, ARRAY_A); |
|
64 | 64 | |
65 | - foreach($arr as $a) |
|
65 | + foreach ($arr as $a) |
|
66 | 66 | { |
67 | 67 | $arrActividades = array('label'=>$a['nombre'], 'value'=>round($a['total'])); |
68 | 68 | |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | GROUP BY a.id |
78 | 78 | ORDER BY a.nombre"; |
79 | 79 | |
80 | - if($arr2 = $db->get_results($sql,ARRAY_A)) |
|
80 | + if ($arr2 = $db->get_results($sql, ARRAY_A)) |
|
81 | 81 | { |
82 | 82 | $arrSubactividades = array(); |
83 | 83 | |
84 | 84 | $i = 0; |
85 | 85 | |
86 | - foreach($arr2 as $a2) |
|
86 | + foreach ($arr2 as $a2) |
|
87 | 87 | { |
88 | 88 | $arrSubactividades[$i] = array('label'=>$a2['nombre'], 'value'=>round($a2['total'])); |
89 | 89 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | |
102 | 102 | // echo $sql."<br/>"; |
103 | 103 | |
104 | - if($arr3 = $db->get_results($sql,ARRAY_A)) |
|
104 | + if ($arr3 = $db->get_results($sql, ARRAY_A)) |
|
105 | 105 | { |
106 | 106 | $arrCategorias = array(); |
107 | 107 | |
108 | - foreach($arr3 as $a3) |
|
108 | + foreach ($arr3 as $a3) |
|
109 | 109 | { |
110 | 110 | $arrCategorias[] = array('label'=>$a3['nombre'], 'value'=>round($a3['total'])); |
111 | 111 | } |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | |
137 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-gases' ) |
|
137 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-gases') |
|
138 | 138 | { |
139 | 139 | |
140 | 140 | |
141 | 141 | |
142 | - $ano = (int)$_REQUEST['ano']; |
|
142 | + $ano = (int) $_REQUEST['ano']; |
|
143 | 143 | |
144 | 144 | $arrReturn = array(); |
145 | 145 | |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | LEFT JOIN gas g ON (e.gas_id = g.id) |
149 | 149 | where e.ano = $ano GROUP BY e.gas_id ORDER BY total DESC"; |
150 | 150 | |
151 | - $arr = $db->get_results($sql,ARRAY_A); |
|
151 | + $arr = $db->get_results($sql, ARRAY_A); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | $arrReturn['gases'][] = 'x'; |
155 | 155 | $arrReturn['valores'][] = 'Gases'; |
156 | 156 | |
157 | - foreach($arr as $a) |
|
157 | + foreach ($arr as $a) |
|
158 | 158 | { |
159 | - $arrReturn['gases'][] = (strpos($a['nombre'], ',')) ? '"'.$a['nombre'].'"' : $a['nombre']; |
|
159 | + $arrReturn['gases'][] = (strpos($a['nombre'], ',')) ? '"'.$a['nombre'].'"' : $a['nombre']; |
|
160 | 160 | $arrReturn['valores'][] = round($a['total']); |
161 | 161 | $arrReturn['colores'][] = $a['color']; |
162 | 162 | } |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-gases-sector' ) |
|
169 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'distribucion-gases-sector') |
|
170 | 170 | { |
171 | 171 | |
172 | 172 | |
173 | - $ano = (int)$_REQUEST['ano']; |
|
173 | + $ano = (int) $_REQUEST['ano']; |
|
174 | 174 | |
175 | 175 | $arrReturn = array(); |
176 | 176 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | LEFT JOIN gas g ON (e.gas_id = g.id) |
182 | 182 | where e.ano = $ano GROUP BY e.gas_id ORDER BY total DESC"; |
183 | 183 | |
184 | - $arrGases = $db->get_results($sql,ARRAY_A); |
|
184 | + $arrGases = $db->get_results($sql, ARRAY_A); |
|
185 | 185 | |
186 | 186 | |
187 | 187 | |
@@ -203,20 +203,20 @@ discard block |
||
203 | 203 | LEFT JOIN sector s ON (e.sector_id = s.id) |
204 | 204 | where e.ano = $ano GROUP BY e.gas_id, e.sector_id ORDER BY total DESC"; |
205 | 205 | |
206 | - $arr = $db->get_results($sql,ARRAY_A); |
|
206 | + $arr = $db->get_results($sql, ARRAY_A); |
|
207 | 207 | |
208 | 208 | $column = 2; |
209 | 209 | |
210 | 210 | |
211 | 211 | |
212 | - foreach($arrSectores as $sector) |
|
212 | + foreach ($arrSectores as $sector) |
|
213 | 213 | { |
214 | 214 | $arrReturn['column_'.$column][] = $sector; |
215 | 215 | |
216 | - foreach($arrGases as $gas) |
|
216 | + foreach ($arrGases as $gas) |
|
217 | 217 | { |
218 | 218 | |
219 | - $arrReturn['column_'.$column][] = returnSectorGas($arr,$sector,$gas['nombre']); |
|
219 | + $arrReturn['column_'.$column][] = returnSectorGas($arr, $sector, $gas['nombre']); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | $arrReturnGases = array('x'); |
227 | 227 | |
228 | - foreach($arrGases as $gas) |
|
228 | + foreach ($arrGases as $gas) |
|
229 | 229 | { |
230 | 230 | |
231 | 231 | $arrReturnGases[] = $gas['nombre']; |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | |
248 | 248 | |
249 | 249 | |
250 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector') |
|
250 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector') |
|
251 | 251 | { |
252 | 252 | |
253 | - $ano = (int)$_REQUEST['ano']; |
|
253 | + $ano = (int) $_REQUEST['ano']; |
|
254 | 254 | |
255 | 255 | $arrReturn = array(); |
256 | 256 | |
@@ -258,32 +258,32 @@ discard block |
||
258 | 258 | FROM sector s |
259 | 259 | WHERE 1 "; |
260 | 260 | |
261 | - $sql.= (!empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') ? "AND s.id = ".$_REQUEST['sector_id'] : ''; |
|
261 | + $sql .= (!empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') ? "AND s.id = ".$_REQUEST['sector_id'] : ''; |
|
262 | 262 | |
263 | - $sql.= " ORDER BY s.nombre "; |
|
263 | + $sql .= " ORDER BY s.nombre "; |
|
264 | 264 | |
265 | - $arrSectores = $db->get_results($sql,ARRAY_A); |
|
265 | + $arrSectores = $db->get_results($sql, ARRAY_A); |
|
266 | 266 | |
267 | 267 | $sql = "SELECT s.nombre as sector, e.ano, sum(e.valor) as total |
268 | 268 | FROM emision e |
269 | 269 | LEFT JOIN sector s ON (e.sector_id = s.id) |
270 | 270 | where 1 "; |
271 | 271 | |
272 | - $sql.= (!empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') ? "AND e.sector_id = ".$_REQUEST['sector_id'] : ''; |
|
272 | + $sql .= (!empty($_REQUEST['sector_id']) && $_REQUEST['sector_id'] != 'all') ? "AND e.sector_id = ".$_REQUEST['sector_id'] : ''; |
|
273 | 273 | |
274 | - $sql.= " GROUP BY e.ano, s.nombre |
|
274 | + $sql .= " GROUP BY e.ano, s.nombre |
|
275 | 275 | ORDER BY e.ano, s.nombre"; |
276 | 276 | |
277 | 277 | // echo $sql; |
278 | 278 | |
279 | - $arr = $db->get_results($sql,ARRAY_A); |
|
279 | + $arr = $db->get_results($sql, ARRAY_A); |
|
280 | 280 | |
281 | 281 | $arrAnos = array(); |
282 | 282 | $arrValores = array(); |
283 | 283 | $arrColores = array(); |
284 | 284 | |
285 | 285 | |
286 | - for($i=1990;$i<=2014;$i++) |
|
286 | + for ($i = 1990; $i <= 2014; $i++) |
|
287 | 287 | { |
288 | 288 | $arrAnos[] = $i; |
289 | 289 | } |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | $column = 2; |
294 | 294 | |
295 | - foreach($arrSectores as $sector) |
|
295 | + foreach ($arrSectores as $sector) |
|
296 | 296 | { |
297 | 297 | $arrReturn['column_'.$column][] = $sector['nombre']; |
298 | - $arrReturn['colores'][] = $sector['color']; |
|
298 | + $arrReturn['colores'][] = $sector['color']; |
|
299 | 299 | |
300 | - foreach($arrAnos as $ano) |
|
300 | + foreach ($arrAnos as $ano) |
|
301 | 301 | { |
302 | 302 | |
303 | - $arrReturn['column_'.$column][] = returnSectorAno($arr,$sector['nombre'],$ano); |
|
303 | + $arrReturn['column_'.$column][] = returnSectorAno($arr, $sector['nombre'], $ano); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector-subactividad') |
|
326 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector-subactividad') |
|
327 | 327 | { |
328 | 328 | |
329 | - $ano = (int)$_REQUEST['ano']; |
|
329 | + $ano = (int) $_REQUEST['ano']; |
|
330 | 330 | |
331 | 331 | $arrReturn = array(); |
332 | 332 | |
@@ -336,34 +336,34 @@ discard block |
||
336 | 336 | INNER JOIN sector s ON (a.sector_id = s.id) |
337 | 337 | WHERE 1 "; |
338 | 338 | |
339 | - $sql.= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."'" : ''; |
|
339 | + $sql .= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."'" : ''; |
|
340 | 340 | |
341 | - $sql.= " ORDER BY sub.nombre "; |
|
341 | + $sql .= " ORDER BY sub.nombre "; |
|
342 | 342 | |
343 | 343 | // echo $sql; |
344 | 344 | |
345 | - $arrSubactividades = $db->get_results($sql,ARRAY_A); |
|
345 | + $arrSubactividades = $db->get_results($sql, ARRAY_A); |
|
346 | 346 | |
347 | 347 | $sql = "SELECT sub.nombre, e.ano, SUM(e.valor) as valor |
348 | 348 | FROM emision e |
349 | 349 | INNER JOIN subactividad sub ON (e.subactividad_id = sub.id) |
350 | 350 | INNER JOIN sector s ON (e.sector_id = s.id)"; |
351 | 351 | |
352 | - $sql.= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."'" : ''; |
|
352 | + $sql .= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."'" : ''; |
|
353 | 353 | |
354 | - $sql.= " GROUP BY e.ano, sub.nombre |
|
354 | + $sql .= " GROUP BY e.ano, sub.nombre |
|
355 | 355 | ORDER BY e.ano, sub.nombre"; |
356 | 356 | |
357 | 357 | // echo $sql; |
358 | 358 | |
359 | - $arr = $db->get_results($sql,ARRAY_A); |
|
359 | + $arr = $db->get_results($sql, ARRAY_A); |
|
360 | 360 | |
361 | 361 | $arrAnos = array(); |
362 | 362 | $arrValores = array(); |
363 | 363 | $arrColores = array(); |
364 | 364 | |
365 | 365 | |
366 | - for($i=1990;$i<=2014;$i++) |
|
366 | + for ($i = 1990; $i <= 2014; $i++) |
|
367 | 367 | { |
368 | 368 | $arrAnos[] = $i; |
369 | 369 | } |
@@ -373,14 +373,14 @@ discard block |
||
373 | 373 | // pr($arrSubactividades); |
374 | 374 | // pr($arr); |
375 | 375 | |
376 | - foreach($arrSubactividades as $subactividad) |
|
376 | + foreach ($arrSubactividades as $subactividad) |
|
377 | 377 | { |
378 | 378 | $arrReturn['column_'.$column][] = $subactividad['nombre']; |
379 | 379 | $arrReturn['groups'][] = $subactividad['nombre']; |
380 | 380 | |
381 | - foreach($arrAnos as $ano) |
|
381 | + foreach ($arrAnos as $ano) |
|
382 | 382 | { |
383 | - $arrReturn['column_'.$column][] = returnSubactividadAno($arr,$subactividad['nombre'],$ano); |
|
383 | + $arrReturn['column_'.$column][] = returnSubactividadAno($arr, $subactividad['nombre'], $ano); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $column++; |
@@ -403,10 +403,10 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | |
406 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector-subactividad-categoria') |
|
406 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'evolucion-sector-subactividad-categoria') |
|
407 | 407 | { |
408 | 408 | |
409 | - $ano = (int)$_REQUEST['ano']; |
|
409 | + $ano = (int) $_REQUEST['ano']; |
|
410 | 410 | |
411 | 411 | $arrReturn = array(); |
412 | 412 | |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | INNER JOIN categoria c ON (e.categoria_id = c.id) |
418 | 418 | WHERE 1 "; |
419 | 419 | |
420 | - $sql.= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."' " : ''; |
|
421 | - $sql.= (!empty($_REQUEST['subactividad_nombre']) && $_REQUEST['subactividad_nombre'] != 'all') ? "AND sub.nombre = '".$_REQUEST['subactividad_nombre']."' " : ''; |
|
420 | + $sql .= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."' " : ''; |
|
421 | + $sql .= (!empty($_REQUEST['subactividad_nombre']) && $_REQUEST['subactividad_nombre'] != 'all') ? "AND sub.nombre = '".$_REQUEST['subactividad_nombre']."' " : ''; |
|
422 | 422 | |
423 | - $sql.= "ORDER BY c.nombre"; |
|
423 | + $sql .= "ORDER BY c.nombre"; |
|
424 | 424 | |
425 | 425 | // echo ($sql); |
426 | 426 | |
427 | - $arrCategorias = $db->get_results($sql,ARRAY_A); |
|
427 | + $arrCategorias = $db->get_results($sql, ARRAY_A); |
|
428 | 428 | |
429 | 429 | |
430 | 430 | |
@@ -436,15 +436,15 @@ discard block |
||
436 | 436 | INNER JOIN sector s ON (e.sector_id = s.id) |
437 | 437 | INNER JOIN categoria c ON (e.categoria_id = c.id) |
438 | 438 | WHERE 1 "; |
439 | - $sql.= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."' " : ''; |
|
440 | - $sql.= (!empty($_REQUEST['subactividad_nombre']) && $_REQUEST['subactividad_nombre'] != 'all') ? "AND sub.nombre = '".$_REQUEST['subactividad_nombre']."' " : ''; |
|
439 | + $sql .= (!empty($_REQUEST['sector_nombre']) && $_REQUEST['sector_nombre'] != 'all') ? "AND s.nombre = '".$_REQUEST['sector_nombre']."' " : ''; |
|
440 | + $sql .= (!empty($_REQUEST['subactividad_nombre']) && $_REQUEST['subactividad_nombre'] != 'all') ? "AND sub.nombre = '".$_REQUEST['subactividad_nombre']."' " : ''; |
|
441 | 441 | |
442 | - $sql.= " GROUP BY e.ano, c.nombre |
|
442 | + $sql .= " GROUP BY e.ano, c.nombre |
|
443 | 443 | ORDER BY sub.nombre, e.ano, c.nombre"; |
444 | 444 | |
445 | 445 | // echo ($sql); |
446 | 446 | |
447 | - $arr = $db->get_results($sql,ARRAY_A); |
|
447 | + $arr = $db->get_results($sql, ARRAY_A); |
|
448 | 448 | |
449 | 449 | // echo $sql;die(); |
450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $arrColores = array(); |
454 | 454 | |
455 | 455 | |
456 | - for($i=1990;$i<=2014;$i++) |
|
456 | + for ($i = 1990; $i <= 2014; $i++) |
|
457 | 457 | { |
458 | 458 | $arrAnos[] = $i; |
459 | 459 | } |
@@ -463,14 +463,14 @@ discard block |
||
463 | 463 | // pr($arrCategorias); |
464 | 464 | // pr($arr); |
465 | 465 | |
466 | - foreach($arrCategorias as $categoria) |
|
466 | + foreach ($arrCategorias as $categoria) |
|
467 | 467 | { |
468 | 468 | $arrReturn['column_'.$column][] = $categoria['nombre']; |
469 | 469 | $arrReturn['groups'][] = $categoria['nombre']; |
470 | 470 | |
471 | - foreach($arrAnos as $ano) |
|
471 | + foreach ($arrAnos as $ano) |
|
472 | 472 | { |
473 | - $arrReturn['column_'.$column][] = returnCategoriaAno($arr,$categoria['nombre'],$ano); |
|
473 | + $arrReturn['column_'.$column][] = returnCategoriaAno($arr, $categoria['nombre'], $ano); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | $column++; |
@@ -493,12 +493,12 @@ discard block |
||
493 | 493 | |
494 | 494 | |
495 | 495 | |
496 | -if( !empty($_REQUEST['f']) && $_REQUEST['f'] == 'indicador') |
|
496 | +if (!empty($_REQUEST['f']) && $_REQUEST['f'] == 'indicador') |
|
497 | 497 | { |
498 | - $indicador_id = (int)$_REQUEST['indicador_id']; |
|
498 | + $indicador_id = (int) $_REQUEST['indicador_id']; |
|
499 | 499 | |
500 | 500 | $sql = "SELECT * FROM indicador WHERE id = $indicador_id"; |
501 | - $arrIndicador = $db->get_row($sql,ARRAY_A); |
|
501 | + $arrIndicador = $db->get_row($sql, ARRAY_A); |
|
502 | 502 | |
503 | 503 | $arrReturn = array(); |
504 | 504 | |
@@ -508,21 +508,21 @@ discard block |
||
508 | 508 | WHERE indicador_id = $indicador_id |
509 | 509 | ORDER BY ano ASC"; |
510 | 510 | |
511 | - $arr = $db->get_results($sql,ARRAY_A); |
|
511 | + $arr = $db->get_results($sql, ARRAY_A); |
|
512 | 512 | |
513 | 513 | |
514 | 514 | |
515 | - foreach($arr as $a) |
|
515 | + foreach ($arr as $a) |
|
516 | 516 | { |
517 | 517 | // SI EL NOMBRE TIENE UNA COMA LO TENGO QUE PONER ENTRE COMILLAS |
518 | - $arrAnos[] = $a['ano']; |
|
518 | + $arrAnos[] = $a['ano']; |
|
519 | 519 | $arrValor[] = $a['valor']; |
520 | 520 | } |
521 | 521 | |
522 | - $arrAnos = array_merge( array('x'), $arrAnos ); |
|
522 | + $arrAnos = array_merge(array('x'), $arrAnos); |
|
523 | 523 | $arrReturn['column_1'] = $arrAnos; |
524 | 524 | |
525 | - $arrValor = array_merge( array($arrIndicador['nombre']), $arrValor ); |
|
525 | + $arrValor = array_merge(array($arrIndicador['nombre']), $arrValor); |
|
526 | 526 | $arrReturn['column_2'] = $arrValor; |
527 | 527 | |
528 | 528 | $arrReturn['unidad'] = $arrIndicador['unidad']; |
@@ -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 | ( |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | $this->select($this->dbname, $this->encoding); |
189 | 189 | } |
190 | 190 | |
191 | - if ( get_magic_quotes_gpc() ) { |
|
191 | + if ( get_magic_quotes_gpc() ) { |
|
192 | 192 | $str = stripslashes($str); |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | 195 | return $this->dbh->escape_string($str); |
196 | 196 | } |
@@ -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,28 +80,28 @@ 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 | |
99 | 98 | $this->dbh->set_charset("utf8"); |
100 | 99 | |
101 | 100 | // Check for connection problem |
102 | - if( $this->dbh->connect_errno ) |
|
101 | + if ($this->dbh->connect_errno) |
|
103 | 102 | { |
104 | 103 | $this->register_error($ezsql_mysqli_str[2].' in '.__FILE__.' on line '.__LINE__); |
105 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[2],E_USER_WARNING) : null; |
|
104 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[2], E_USER_WARNING) : null; |
|
106 | 105 | } |
107 | 106 | else |
108 | 107 | { |
@@ -123,47 +122,47 @@ discard block |
||
123 | 122 | * Try to select a mySQL database |
124 | 123 | */ |
125 | 124 | |
126 | - function select($dbname='', $encoding='') |
|
125 | + function select($dbname = '', $encoding = '') |
|
127 | 126 | { |
128 | 127 | global $ezsql_mysqli_str; $return_val = false; |
129 | 128 | |
130 | 129 | // Must have a database name |
131 | - if ( ! $dbname ) |
|
130 | + if (!$dbname) |
|
132 | 131 | { |
133 | 132 | $this->register_error($ezsql_mysqli_str[3].' in '.__FILE__.' on line '.__LINE__); |
134 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[3],E_USER_WARNING) : null; |
|
133 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[3], E_USER_WARNING) : null; |
|
135 | 134 | } |
136 | 135 | |
137 | 136 | // Must have an active database connection |
138 | - else if ( ! $this->dbh ) |
|
137 | + else if (!$this->dbh) |
|
139 | 138 | { |
140 | 139 | $this->register_error($ezsql_mysqli_str[4].' in '.__FILE__.' on line '.__LINE__); |
141 | - $this->show_errors ? trigger_error($ezsql_mysqli_str[4],E_USER_WARNING) : null; |
|
140 | + $this->show_errors ? trigger_error($ezsql_mysqli_str[4], E_USER_WARNING) : null; |
|
142 | 141 | } |
143 | 142 | |
144 | 143 | // Try to connect to the database |
145 | - else if ( !@$this->dbh->select_db($dbname) ) |
|
144 | + else if (!@$this->dbh->select_db($dbname)) |
|
146 | 145 | { |
147 | 146 | // Try to get error supplied by mysql if not use our own |
148 | - if ( !$str = @$this->dbh->error) |
|
147 | + if (!$str = @$this->dbh->error) |
|
149 | 148 | $str = $ezsql_mysqli_str[5]; |
150 | 149 | |
151 | 150 | $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
152 | - $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
|
151 | + $this->show_errors ? trigger_error($str, E_USER_WARNING) : null; |
|
153 | 152 | } |
154 | 153 | else |
155 | 154 | { |
156 | 155 | $this->dbname = $dbname; |
157 | - if($encoding!='') |
|
156 | + if ($encoding != '') |
|
158 | 157 | { |
159 | - $encoding = strtolower(str_replace("-","",$encoding)); |
|
158 | + $encoding = strtolower(str_replace("-", "", $encoding)); |
|
160 | 159 | $charsets = array(); |
161 | 160 | $result = $this->dbh->query("SHOW CHARACTER SET"); |
162 | - while($row = $result->fetch_array(MYSQLI_ASSOC)) |
|
161 | + while ($row = $result->fetch_array(MYSQLI_ASSOC)) |
|
163 | 162 | { |
164 | 163 | $charsets[] = $row["Charset"]; |
165 | 164 | } |
166 | - if(in_array($encoding,$charsets)){ |
|
165 | + if (in_array($encoding, $charsets)) { |
|
167 | 166 | $this->dbh->set_charset($encoding); |
168 | 167 | } |
169 | 168 | } |
@@ -182,13 +181,13 @@ discard block |
||
182 | 181 | function escape($str) |
183 | 182 | { |
184 | 183 | // If there is no existing database connection then try to connect |
185 | - if ( ! isset($this->dbh) || ! $this->dbh ) |
|
184 | + if (!isset($this->dbh) || !$this->dbh) |
|
186 | 185 | { |
187 | 186 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
188 | 187 | $this->select($this->dbname, $this->encoding); |
189 | 188 | } |
190 | 189 | |
191 | - if ( get_magic_quotes_gpc() ) { |
|
190 | + if (get_magic_quotes_gpc()) { |
|
192 | 191 | $str = stripslashes($str); |
193 | 192 | } |
194 | 193 | |
@@ -213,10 +212,10 @@ discard block |
||
213 | 212 | { |
214 | 213 | |
215 | 214 | // This keeps the connection alive for very long running scripts |
216 | - if ( $this->count(false) >= 500 ) |
|
215 | + if ($this->count(false) >= 500) |
|
217 | 216 | { |
218 | 217 | $this->disconnect(); |
219 | - $this->quick_connect($this->dbuser,$this->dbpassword,$this->dbname,$this->dbhost,$this->dbport,$this->encoding); |
|
218 | + $this->quick_connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport, $this->encoding); |
|
220 | 219 | } |
221 | 220 | |
222 | 221 | // Initialise return |
@@ -241,13 +240,13 @@ discard block |
||
241 | 240 | $this->timer_start($this->num_queries); |
242 | 241 | |
243 | 242 | // Use core file cache function |
244 | - if ( $cache = $this->get_cache($query) ) |
|
243 | + if ($cache = $this->get_cache($query)) |
|
245 | 244 | { |
246 | 245 | // Keep tack of how long all queries have taken |
247 | 246 | $this->timer_update_global($this->num_queries); |
248 | 247 | |
249 | 248 | // Trace all queries |
250 | - if ( $this->use_trace_log ) |
|
249 | + if ($this->use_trace_log) |
|
251 | 250 | { |
252 | 251 | $this->trace_log[] = $this->debug(false); |
253 | 252 | } |
@@ -256,12 +255,12 @@ discard block |
||
256 | 255 | } |
257 | 256 | |
258 | 257 | // If there is no existing database connection then try to connect |
259 | - if ( ! isset($this->dbh) || ! $this->dbh ) |
|
258 | + if (!isset($this->dbh) || !$this->dbh) |
|
260 | 259 | { |
261 | 260 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
262 | - $this->select($this->dbname,$this->encoding); |
|
261 | + $this->select($this->dbname, $this->encoding); |
|
263 | 262 | // No existing connection at this point means the server is unreachable |
264 | - if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) |
|
263 | + if (!isset($this->dbh) || !$this->dbh || $this->dbh->connect_errno) |
|
265 | 264 | return false; |
266 | 265 | } |
267 | 266 | |
@@ -269,21 +268,21 @@ discard block |
||
269 | 268 | $this->result = @$this->dbh->query($query); |
270 | 269 | |
271 | 270 | // If there is an error then take note of it.. |
272 | - if ( $str = @$this->dbh->error ) |
|
271 | + if ($str = @$this->dbh->error) |
|
273 | 272 | { |
274 | 273 | $this->register_error($str); |
275 | - $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
|
274 | + $this->show_errors ? trigger_error($str, E_USER_WARNING) : null; |
|
276 | 275 | return false; |
277 | 276 | } |
278 | 277 | |
279 | 278 | // Query was a Data Manipulation Query (insert, delete, update, replace, ...) |
280 | - if ( !is_object($this->result) ) |
|
279 | + if (!is_object($this->result)) |
|
281 | 280 | { |
282 | 281 | $is_insert = true; |
283 | 282 | $this->rows_affected = @$this->dbh->affected_rows; |
284 | 283 | |
285 | 284 | // Take note of the insert_id |
286 | - if ( preg_match("/^(insert|replace)\s+/i",$query) ) |
|
285 | + if (preg_match("/^(insert|replace)\s+/i", $query)) |
|
287 | 286 | { |
288 | 287 | $this->insert_id = @$this->dbh->insert_id; |
289 | 288 | } |
@@ -297,7 +296,7 @@ discard block |
||
297 | 296 | $is_insert = false; |
298 | 297 | |
299 | 298 | // Take note of column info |
300 | - $i=0; |
|
299 | + $i = 0; |
|
301 | 300 | while ($i < @$this->result->field_count) |
302 | 301 | { |
303 | 302 | $this->col_info[$i] = @$this->result->fetch_field(); |
@@ -305,8 +304,8 @@ discard block |
||
305 | 304 | } |
306 | 305 | |
307 | 306 | // Store Query Results |
308 | - $num_rows=0; |
|
309 | - while ( $row = @$this->result->fetch_object() ) |
|
307 | + $num_rows = 0; |
|
308 | + while ($row = @$this->result->fetch_object()) |
|
310 | 309 | { |
311 | 310 | // Store relults as an objects within main array |
312 | 311 | $this->last_result[$num_rows] = $row; |
@@ -323,16 +322,16 @@ discard block |
||
323 | 322 | } |
324 | 323 | |
325 | 324 | // disk caching of queries |
326 | - $this->store_cache($query,$is_insert); |
|
325 | + $this->store_cache($query, $is_insert); |
|
327 | 326 | |
328 | 327 | // If debug ALL queries |
329 | - $this->trace || $this->debug_all ? $this->debug() : null ; |
|
328 | + $this->trace || $this->debug_all ? $this->debug() : null; |
|
330 | 329 | |
331 | 330 | // Keep tack of how long all queries have taken |
332 | 331 | $this->timer_update_global($this->num_queries); |
333 | 332 | |
334 | 333 | // Trace all queries |
335 | - if ( $this->use_trace_log ) |
|
334 | + if ($this->use_trace_log) |
|
336 | 335 | { |
337 | 336 | $this->trace_log[] = $this->debug(false); |
338 | 337 | } |
@@ -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 | |
@@ -103,8 +109,7 @@ discard block |
||
103 | 109 | { |
104 | 110 | $this->register_error($ezsql_mysqli_str[2].' in '.__FILE__.' on line '.__LINE__); |
105 | 111 | $this->show_errors ? trigger_error($ezsql_mysqli_str[2],E_USER_WARNING) : null; |
106 | - } |
|
107 | - else |
|
112 | + } else |
|
108 | 113 | { |
109 | 114 | $this->dbuser = $dbuser; |
110 | 115 | $this->dbpassword = $dbpassword; |
@@ -145,13 +150,13 @@ discard block |
||
145 | 150 | else if ( !@$this->dbh->select_db($dbname) ) |
146 | 151 | { |
147 | 152 | // Try to get error supplied by mysql if not use our own |
148 | - if ( !$str = @$this->dbh->error) |
|
149 | - $str = $ezsql_mysqli_str[5]; |
|
153 | + if ( !$str = @$this->dbh->error) { |
|
154 | + $str = $ezsql_mysqli_str[5]; |
|
155 | + } |
|
150 | 156 | |
151 | 157 | $this->register_error($str.' in '.__FILE__.' on line '.__LINE__); |
152 | 158 | $this->show_errors ? trigger_error($str,E_USER_WARNING) : null; |
153 | - } |
|
154 | - else |
|
159 | + } else |
|
155 | 160 | { |
156 | 161 | $this->dbname = $dbname; |
157 | 162 | if($encoding!='') |
@@ -261,8 +266,9 @@ discard block |
||
261 | 266 | $this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport); |
262 | 267 | $this->select($this->dbname,$this->encoding); |
263 | 268 | // No existing connection at this point means the server is unreachable |
264 | - if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) |
|
265 | - return false; |
|
269 | + if ( ! isset($this->dbh) || ! $this->dbh || $this->dbh->connect_errno ) { |
|
270 | + return false; |
|
271 | + } |
|
266 | 272 | } |
267 | 273 | |
268 | 274 | // Perform the query via std mysql_query function.. |