@@ -138,7 +138,7 @@ |
||
| 138 | 138 | * Efectua operaciones SQL sobre la base de datos |
| 139 | 139 | * |
| 140 | 140 | * @param string $sql_query |
| 141 | - * @return resource or false |
|
| 141 | + * @return resource|null or false |
|
| 142 | 142 | */ |
| 143 | 143 | public function query($sql_query) |
| 144 | 144 | { |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | * @param int $opt |
| 176 | 176 | * @return array |
| 177 | 177 | */ |
| 178 | - public function fetch_array($result_query=NULL, $opt=MYSQL_BOTH) |
|
| 178 | + public function fetch_array($result_query = NULL, $opt = MYSQL_BOTH) |
|
| 179 | 179 | { |
| 180 | - $result=array(); |
|
| 180 | + $result = array(); |
|
| 181 | 181 | if (!$result_query) { |
| 182 | 182 | $result_query = $this->last_result_query; |
| 183 | 183 | if (!$result_query) { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | /** |
| 217 | 217 | * Devuelve el numero de filas de un select |
| 218 | 218 | */ |
| 219 | - public function num_rows($result_query='') |
|
| 219 | + public function num_rows($result_query = '') |
|
| 220 | 220 | { |
| 221 | 221 | // GDS Interbase no soporta esta funcion (No debe ser usada) |
| 222 | 222 | return false; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param resource $result_query |
| 230 | 230 | * @return string |
| 231 | 231 | */ |
| 232 | - public function field_name($number, $result_query='') |
|
| 232 | + public function field_name($number, $result_query = '') |
|
| 233 | 233 | { |
| 234 | 234 | |
| 235 | 235 | if (!$result_query) { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param resource $result_query |
| 253 | 253 | * @return boolean |
| 254 | 254 | */ |
| 255 | - public function data_seek($number, $result_query=NULL) |
|
| 255 | + public function data_seek($number, $result_query = NULL) |
|
| 256 | 256 | { |
| 257 | 257 | if (!$result_query) { |
| 258 | 258 | $result_query = $this->last_result_query; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param resource $result_query |
| 274 | 274 | * @return int |
| 275 | 275 | */ |
| 276 | - public function affected_rows($result_query=NULL) |
|
| 276 | + public function affected_rows($result_query = NULL) |
|
| 277 | 277 | { |
| 278 | 278 | if (($numberRows = ibase_affected_rows()) !== false) { |
| 279 | 279 | return $numberRows; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return string |
| 289 | 289 | */ |
| 290 | - public function error($err='') |
|
| 290 | + public function error($err = '') |
|
| 291 | 291 | { |
| 292 | 292 | if (!$this->id_connection) { |
| 293 | 293 | $this->last_error = ibase_errmsg() ? ibase_errmsg() : "[Error Desconocido en Firebird: $err]"; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | return $this->last_error; |
| 298 | 298 | } |
| 299 | 299 | $this->last_error = ibase_errmsg() ? ibase_errmsg() : "[Error Desconocido en Firebird: $err]"; |
| 300 | - $this->last_error.= $err; |
|
| 300 | + $this->last_error .= $err; |
|
| 301 | 301 | if ($this->logger) { |
| 302 | 302 | Logger::error($this->last_error); |
| 303 | 303 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return int |
| 338 | 338 | */ |
| 339 | - public function last_insert_id($table='', $primary_key='') |
|
| 339 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 340 | 340 | { |
| 341 | 341 | return ibase_insert_id($this->id_connection); |
| 342 | 342 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @param string $table |
| 348 | 348 | * @return boolean |
| 349 | 349 | */ |
| 350 | - public function table_exists($table, $schema='') |
|
| 350 | + public function table_exists($table, $schema = '') |
|
| 351 | 351 | { |
| 352 | 352 | $table = strtoupper(addslashes("$table")); |
| 353 | 353 | // NOT LIKE 'RDB\$%' |
@@ -367,11 +367,11 @@ discard block |
||
| 367 | 367 | $sql_new = $sql; |
| 368 | 368 | |
| 369 | 369 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 370 | - $sql_new.=" FIRST $params[limit]"; |
|
| 370 | + $sql_new .= " FIRST $params[limit]"; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 374 | - $sql_new.=" SKIP $params[offset]"; |
|
| 374 | + $sql_new .= " SKIP $params[offset]"; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | return $sql_new; |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param string $table |
| 384 | 384 | * @return boolean |
| 385 | 385 | */ |
| 386 | - public function drop_table($table, $if_exists=true) |
|
| 386 | + public function drop_table($table, $if_exists = true) |
|
| 387 | 387 | { |
| 388 | 388 | if ($if_exists) { |
| 389 | 389 | if ($this->table_exists($table)) { |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * @param array $definition |
| 410 | 410 | * @return resource |
| 411 | 411 | */ |
| 412 | - public function create_table($table, $definition, $index=array()) |
|
| 412 | + public function create_table($table, $definition, $index = array()) |
|
| 413 | 413 | { |
| 414 | 414 | $create_sql = "CREATE TABLE $table ("; |
| 415 | 415 | if (!is_array($definition)) { |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 465 | 465 | } |
| 466 | - $create_sql.= join(',', $create_lines); |
|
| 466 | + $create_sql .= join(',', $create_lines); |
|
| 467 | 467 | $last_lines = array(); |
| 468 | 468 | if (count($primary)) { |
| 469 | 469 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $last_lines[] = join(',', $unique_index); |
| 476 | 476 | } |
| 477 | 477 | if (count($last_lines)) { |
| 478 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 478 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 479 | 479 | } |
| 480 | 480 | return $this->query($create_sql); |
| 481 | 481 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | * @param string $table |
| 497 | 497 | * @return array |
| 498 | 498 | */ |
| 499 | - public function describe_table($table, $schema='') |
|
| 499 | + public function describe_table($table, $schema = '') |
|
| 500 | 500 | { |
| 501 | 501 | if ($schema == '') { |
| 502 | 502 | return $this->fetch_all("DESCRIBE $table"); |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * @param string $table |
| 581 | 581 | * @param array $values |
| 582 | 582 | * @param array $fields |
| 583 | - * @return boolean |
|
| 583 | + * @return resource|null |
|
| 584 | 584 | */ |
| 585 | 585 | public function insert($table, $values, $fields=null) |
| 586 | 586 | { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | * @param array $fields |
| 596 | 596 | * @param array $values |
| 597 | 597 | * @param string $where_condition |
| 598 | - * @return boolean |
|
| 598 | + * @return resource|null |
|
| 599 | 599 | */ |
| 600 | 600 | public function update($table, $fields, $values, $where_condition=null) |
| 601 | 601 | { |
@@ -408,9 +408,9 @@ |
||
| 408 | 408 | * @return string |
| 409 | 409 | */ |
| 410 | 410 | public function limit($sql){ |
| 411 | - /** |
|
| 412 | - * No esta soportado por Informix |
|
| 413 | - */ |
|
| 411 | + /** |
|
| 412 | + * No esta soportado por Informix |
|
| 413 | + */ |
|
| 414 | 414 | return "$sql \n"; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param int $opt |
| 194 | 194 | * @return array |
| 195 | 195 | */ |
| 196 | - public function fetch_array($result_query=NULL, $opt=2) |
|
| 196 | + public function fetch_array($result_query = NULL, $opt = 2) |
|
| 197 | 197 | { |
| 198 | 198 | |
| 199 | 199 | if (!$result_query) { |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param resource $result_query |
| 254 | 254 | * @return int |
| 255 | 255 | */ |
| 256 | - public function num_rows($result_query=NULL) |
|
| 256 | + public function num_rows($result_query = NULL) |
|
| 257 | 257 | { |
| 258 | 258 | |
| 259 | 259 | if (!$result_query) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @param resource $result_query |
| 283 | 283 | * @return string |
| 284 | 284 | */ |
| 285 | - public function field_name($number, $result_query=NULL) |
|
| 285 | + public function field_name($number, $result_query = NULL) |
|
| 286 | 286 | { |
| 287 | 287 | |
| 288 | 288 | if (!$result_query) { |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @param resource $result_query |
| 309 | 309 | * @return boolean |
| 310 | 310 | */ |
| 311 | - public function data_seek($number, $result_query=NULL) |
|
| 311 | + public function data_seek($number, $result_query = NULL) |
|
| 312 | 312 | { |
| 313 | 313 | if (!$result_query) { |
| 314 | 314 | $result_query = $this->last_result_query; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param resource $result_query |
| 330 | 330 | * @return int |
| 331 | 331 | */ |
| 332 | - public function affected_rows($result_query=NULL) |
|
| 332 | + public function affected_rows($result_query = NULL) |
|
| 333 | 333 | { |
| 334 | 334 | if (!$result_query) { |
| 335 | 335 | $result_query = $this->last_result_query; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * |
| 350 | 350 | * @return string |
| 351 | 351 | */ |
| 352 | - public function error($err='') |
|
| 352 | + public function error($err = '') |
|
| 353 | 353 | { |
| 354 | 354 | if (!$this->id_connection) { |
| 355 | 355 | $this->last_error = ifx_errormsg() ? ifx_errormsg() : "[Error Desconocido en Informix: $err]"; |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | return $this->last_error; |
| 360 | 360 | } |
| 361 | 361 | $this->last_error = ifx_errormsg($this->id_connection) ? ifx_errormsg($this->id_connection) : "[Error Desconocido en Informix: $err]"; |
| 362 | - $this->last_error.= $err; |
|
| 362 | + $this->last_error .= $err; |
|
| 363 | 363 | if ($this->logger) { |
| 364 | 364 | Logger::error($this->last_error); |
| 365 | 365 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | * |
| 382 | 382 | * @return int |
| 383 | 383 | */ |
| 384 | - public function last_insert_id($table='', $primary_key='') |
|
| 384 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 385 | 385 | { |
| 386 | 386 | $sqlca = ifx_getsqlca($this->last_result_query); |
| 387 | 387 | return $sqlca["sqlerrd1"]; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @param string $table |
| 394 | 394 | * @return integer |
| 395 | 395 | */ |
| 396 | - public function table_exists($table, $schema='') |
|
| 396 | + public function table_exists($table, $schema = '') |
|
| 397 | 397 | { |
| 398 | 398 | // Informix no soporta schemas |
| 399 | 399 | $table = addslashes("$table"); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @param string $sql |
| 408 | 408 | * @return string |
| 409 | 409 | */ |
| 410 | - public function limit($sql){ |
|
| 410 | + public function limit($sql) { |
|
| 411 | 411 | /** |
| 412 | 412 | * No esta soportado por Informix |
| 413 | 413 | */ |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | * @param string $table |
| 422 | 422 | * @return boolean |
| 423 | 423 | */ |
| 424 | - public function drop_table($table, $if_exists=true) |
|
| 424 | + public function drop_table($table, $if_exists = true) |
|
| 425 | 425 | { |
| 426 | 426 | if ($if_exists) { |
| 427 | 427 | if ($this->table_exists($table)) { |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param array $definition |
| 450 | 450 | * @return resource |
| 451 | 451 | */ |
| 452 | - public function create_table($table, $definition, $index=array()) |
|
| 452 | + public function create_table($table, $definition, $index = array()) |
|
| 453 | 453 | { |
| 454 | 454 | $create_sql = "CREATE TABLE $table ("; |
| 455 | 455 | if (!is_array($definition)) { |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | } |
| 500 | 500 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 501 | 501 | } |
| 502 | - $create_sql.= join(',', $create_lines); |
|
| 502 | + $create_sql .= join(',', $create_lines); |
|
| 503 | 503 | $last_lines = array(); |
| 504 | 504 | if (count($primary)) { |
| 505 | 505 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | $last_lines[] = join(',', $unique_index); |
| 512 | 512 | } |
| 513 | 513 | if (count($last_lines)) { |
| 514 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 514 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 515 | 515 | } |
| 516 | 516 | $this->set_return_rows(false); |
| 517 | 517 | return $this->query($create_sql); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param string $table |
| 534 | 534 | * @return array |
| 535 | 535 | */ |
| 536 | - public function describe_table($table, $schema='') |
|
| 536 | + public function describe_table($table, $schema = '') |
|
| 537 | 537 | { |
| 538 | 538 | |
| 539 | 539 | // Informix no soporta schemas |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | * @param array $fields |
| 583 | 583 | * @return boolean |
| 584 | 584 | */ |
| 585 | - public function insert($table, $values, $fields=null) |
|
| 585 | + public function insert($table, $values, $fields = null) |
|
| 586 | 586 | { |
| 587 | 587 | $this->set_return_rows(false); |
| 588 | 588 | return parent::insert($table, $values, $fields); |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @param string $where_condition |
| 598 | 598 | * @return boolean |
| 599 | 599 | */ |
| 600 | - public function update($table, $fields, $values, $where_condition=null) |
|
| 600 | + public function update($table, $fields, $values, $where_condition = null) |
|
| 601 | 601 | { |
| 602 | 602 | $this->set_return_rows(false); |
| 603 | 603 | return parent::update($table, $fields, $values, $where_condition); |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | * |
| 621 | 621 | * @param boolean $value |
| 622 | 622 | */ |
| 623 | - public function set_return_rows($value=true) |
|
| 623 | + public function set_return_rows($value = true) |
|
| 624 | 624 | { |
| 625 | 625 | $this->return_rows = $value; |
| 626 | 626 | } |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | /** |
| 153 | 153 | * Cierra la Conexión al Motor de Base de datos |
| 154 | 154 | * |
| 155 | - * @return boolean |
|
| 155 | + * @return boolean|null |
|
| 156 | 156 | */ |
| 157 | 157 | public function close() |
| 158 | 158 | { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $this->id_connection = new mysqli($config['host'], $config['username'], $config['password'], $config['name'], $config['port']); |
| 123 | 123 | //no se usa $object->error() ya que solo funciona a partir de 5.2.9 y 5.3 |
| 124 | - if (mysqli_connect_error ()) throw new KumbiaException(mysqli_connect_error()); |
|
| 124 | + if (mysqli_connect_error()) throw new KumbiaException(mysqli_connect_error()); |
|
| 125 | 125 | //Selecciona charset |
| 126 | 126 | if (isset($config['charset'])) $this->id_connection->set_charset($config['charset']); |
| 127 | 127 | return TRUE; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param int $opt |
| 169 | 169 | * @return array |
| 170 | 170 | */ |
| 171 | - public function fetch_array($result_query='', $opt=MYSQLI_BOTH) |
|
| 171 | + public function fetch_array($result_query = '', $opt = MYSQLI_BOTH) |
|
| 172 | 172 | { |
| 173 | 173 | if (!$result_query) { |
| 174 | 174 | $result_query = $this->last_result_query; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | /** |
| 193 | 193 | * Devuelve el numero de filas de un select |
| 194 | 194 | */ |
| 195 | - public function num_rows($result_query='') |
|
| 195 | + public function num_rows($result_query = '') |
|
| 196 | 196 | { |
| 197 | 197 | if (!$result_query) { |
| 198 | 198 | $result_query = $this->last_result_query; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param resource $result_query |
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | - public function field_name($number, $result_query='') |
|
| 217 | + public function field_name($number, $result_query = '') |
|
| 218 | 218 | { |
| 219 | 219 | |
| 220 | 220 | if (!$result_query) { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param resource $result_query |
| 239 | 239 | * @return boolean |
| 240 | 240 | */ |
| 241 | - public function data_seek($number, $result_query='') |
|
| 241 | + public function data_seek($number, $result_query = '') |
|
| 242 | 242 | { |
| 243 | 243 | if (!$result_query) { |
| 244 | 244 | $result_query = $this->last_result_query; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param resource $result_query |
| 260 | 260 | * @return int |
| 261 | 261 | */ |
| 262 | - public function affected_rows($result_query='') |
|
| 262 | + public function affected_rows($result_query = '') |
|
| 263 | 263 | { |
| 264 | 264 | if (($numberRows = mysqli_affected_rows($this->id_connection)) !== false) { |
| 265 | 265 | return $numberRows; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return string |
| 275 | 275 | */ |
| 276 | - public function error($err='') |
|
| 276 | + public function error($err = '') |
|
| 277 | 277 | { |
| 278 | 278 | $this->last_error = mysqli_error($this->id_connection) ? mysqli_error($this->id_connection) : "[Error Desconocido en MySQL: $err]"; |
| 279 | - $this->last_error.= $err; |
|
| 279 | + $this->last_error .= $err; |
|
| 280 | 280 | if ($this->logger) { |
| 281 | 281 | Logger::error($this->last_error); |
| 282 | 282 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return int |
| 300 | 300 | */ |
| 301 | - public function last_insert_id($table='', $primary_key='') |
|
| 301 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 302 | 302 | { |
| 303 | 303 | return mysqli_insert_id($this->id_connection); |
| 304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @param string $table |
| 310 | 310 | * @return boolean |
| 311 | 311 | */ |
| 312 | - public function table_exists($table, $schema='') |
|
| 312 | + public function table_exists($table, $schema = '') |
|
| 313 | 313 | { |
| 314 | 314 | $table = addslashes("$table"); |
| 315 | 315 | if ($schema == '') { |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | $sql_new = $sql; |
| 334 | 334 | |
| 335 | 335 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 336 | - $sql_new.=" LIMIT $params[limit]"; |
|
| 336 | + $sql_new .= " LIMIT $params[limit]"; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 340 | - $sql_new.=" OFFSET $params[offset]"; |
|
| 340 | + $sql_new .= " OFFSET $params[offset]"; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return $sql_new; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * @param string $table |
| 350 | 350 | * @return resource |
| 351 | 351 | */ |
| 352 | - public function drop_table($table, $if_exists=true) |
|
| 352 | + public function drop_table($table, $if_exists = true) |
|
| 353 | 353 | { |
| 354 | 354 | if ($if_exists) { |
| 355 | 355 | return $this->query("DROP TABLE IF EXISTS $table"); |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @param array $definition |
| 372 | 372 | * @return resource |
| 373 | 373 | */ |
| 374 | - public function create_table($table, $definition, $index=array()) |
|
| 374 | + public function create_table($table, $definition, $index = array()) |
|
| 375 | 375 | { |
| 376 | 376 | $create_sql = "CREATE TABLE $table ("; |
| 377 | 377 | if (!is_array($definition)) { |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | $create_lines[] = "`$field` " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 423 | 423 | } |
| 424 | - $create_sql.= join(',', $create_lines); |
|
| 424 | + $create_sql .= join(',', $create_lines); |
|
| 425 | 425 | $last_lines = array(); |
| 426 | 426 | if (count($primary)) { |
| 427 | 427 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $last_lines[] = join(',', $unique_index); |
| 434 | 434 | } |
| 435 | 435 | if (count($last_lines)) { |
| 436 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 436 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 437 | 437 | } |
| 438 | 438 | return $this->query($create_sql); |
| 439 | 439 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @param string $table |
| 455 | 455 | * @return array |
| 456 | 456 | */ |
| 457 | - public function describe_table($table, $schema='') |
|
| 457 | + public function describe_table($table, $schema = '') |
|
| 458 | 458 | { |
| 459 | 459 | if ($schema == '') { |
| 460 | 460 | return $this->fetch_all("DESCRIBE `$table`"); |
@@ -117,13 +117,19 @@ |
||
| 117 | 117 | */ |
| 118 | 118 | public function connect($config) |
| 119 | 119 | { |
| 120 | - if (!extension_loaded('mysqli')) throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysqli'); |
|
| 120 | + if (!extension_loaded('mysqli')) { |
|
| 121 | + throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mysqli'); |
|
| 122 | + } |
|
| 121 | 123 | |
| 122 | 124 | $this->id_connection = new mysqli($config['host'], $config['username'], $config['password'], $config['name'], $config['port']); |
| 123 | 125 | //no se usa $object->error() ya que solo funciona a partir de 5.2.9 y 5.3 |
| 124 | - if (mysqli_connect_error ()) throw new KumbiaException(mysqli_connect_error()); |
|
| 126 | + if (mysqli_connect_error ()) { |
|
| 127 | + throw new KumbiaException(mysqli_connect_error()); |
|
| 128 | + } |
|
| 125 | 129 | //Selecciona charset |
| 126 | - if (isset($config['charset'])) $this->id_connection->set_charset($config['charset']); |
|
| 130 | + if (isset($config['charset'])) { |
|
| 131 | + $this->id_connection->set_charset($config['charset']); |
|
| 132 | + } |
|
| 127 | 133 | return TRUE; |
| 128 | 134 | } |
| 129 | 135 | |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | /** |
| 93 | 93 | * Devuelve el ultimo id autonumerico generado en la BD |
| 94 | 94 | * |
| 95 | - * @return integer |
|
| 95 | + * @return string |
|
| 96 | 96 | */ |
| 97 | 97 | public function last_insert_id($table='', $primary_key='') |
| 98 | 98 | { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return integer |
| 96 | 96 | */ |
| 97 | - public function last_insert_id($table='', $primary_key='') |
|
| 97 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 98 | 98 | { |
| 99 | 99 | return $this->pdo->lastInsertId("{$table}_{$primary_key}_seq"); |
| 100 | 100 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param string $table |
| 106 | 106 | * @return boolean |
| 107 | 107 | */ |
| 108 | - function table_exists($table, $schema='') |
|
| 108 | + function table_exists($table, $schema = '') |
|
| 109 | 109 | { |
| 110 | 110 | $table = addslashes(strtolower($table)); |
| 111 | 111 | if (strpos($table, ".")) { |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $sql_new = $sql; |
| 133 | 133 | |
| 134 | 134 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 135 | - $sql_new.=" LIMIT $params[limit]"; |
|
| 135 | + $sql_new .= " LIMIT $params[limit]"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 139 | - $sql_new.=" OFFSET $params[offset]"; |
|
| 139 | + $sql_new .= " OFFSET $params[offset]"; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return $sql_new; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $table |
| 149 | 149 | * @return boolean |
| 150 | 150 | */ |
| 151 | - public function drop_table($table, $if_exists=true) |
|
| 151 | + public function drop_table($table, $if_exists = true) |
|
| 152 | 152 | { |
| 153 | 153 | if ($if_exists) { |
| 154 | 154 | if ($this->table_exists($table)) { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @param array $definition |
| 174 | 174 | * @return boolean |
| 175 | 175 | */ |
| 176 | - public function create_table($table, $definition, $index=array()) |
|
| 176 | + public function create_table($table, $definition, $index = array()) |
|
| 177 | 177 | { |
| 178 | 178 | $create_sql = "CREATE TABLE $table ("; |
| 179 | 179 | if (!is_array($definition)) { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 225 | 225 | } |
| 226 | - $create_sql.= join(',', $create_lines); |
|
| 226 | + $create_sql .= join(',', $create_lines); |
|
| 227 | 227 | $last_lines = array(); |
| 228 | 228 | if (count($primary)) { |
| 229 | 229 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $last_lines[] = join(',', $unique_index); |
| 236 | 236 | } |
| 237 | 237 | if (count($last_lines)) { |
| 238 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 238 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 239 | 239 | } |
| 240 | 240 | return $this->query($create_sql); |
| 241 | 241 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param string $table |
| 265 | 265 | * @return array |
| 266 | 266 | */ |
| 267 | - public function describe_table($table, $schema='') |
|
| 267 | + public function describe_table($table, $schema = '') |
|
| 268 | 268 | { |
| 269 | 269 | $describe = $this->fetch_all("SELECT a.attname AS Field, t.typname AS Type, |
| 270 | 270 | CASE WHEN attnotnull=false THEN 'YES' ELSE 'NO' END AS Null, |
@@ -145,7 +145,7 @@ |
||
| 145 | 145 | * |
| 146 | 146 | * @param string $table |
| 147 | 147 | * @param array $definition |
| 148 | - * @return boolean |
|
| 148 | + * @return integer |
|
| 149 | 149 | */ |
| 150 | 150 | public function create_table($table, $definition, $index=array()) |
| 151 | 151 | { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $table |
| 92 | 92 | * @return boolean |
| 93 | 93 | */ |
| 94 | - public function table_exists($table, $schema='') |
|
| 94 | + public function table_exists($table, $schema = '') |
|
| 95 | 95 | { |
| 96 | 96 | $table = strtolower($table); |
| 97 | 97 | $num = $this->fetch_one("SELECT COUNT(*) FROM sqlite_master WHERE name = '$table'"); |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | $sql_new = $sql; |
| 111 | 111 | |
| 112 | 112 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 113 | - $sql_new.=" LIMIT $params[limit]"; |
|
| 113 | + $sql_new .= " LIMIT $params[limit]"; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 117 | - $sql_new.=" OFFSET $params[offset]"; |
|
| 117 | + $sql_new .= " OFFSET $params[offset]"; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $sql_new; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string $table |
| 127 | 127 | * @return boolean |
| 128 | 128 | */ |
| 129 | - public function drop_table($table, $if_exists=true) |
|
| 129 | + public function drop_table($table, $if_exists = true) |
|
| 130 | 130 | { |
| 131 | 131 | if ($if_exists) { |
| 132 | 132 | return $this->query("DROP TABLE IF EXISTS $table"); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param array $definition |
| 148 | 148 | * @return boolean |
| 149 | 149 | */ |
| 150 | - public function create_table($table, $definition, $index=array()) |
|
| 150 | + public function create_table($table, $definition, $index = array()) |
|
| 151 | 151 | { |
| 152 | 152 | $create_sql = "CREATE TABLE $table ("; |
| 153 | 153 | if (!is_array($definition)) { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 199 | 199 | } |
| 200 | - $create_sql.= join(',', $create_lines); |
|
| 200 | + $create_sql .= join(',', $create_lines); |
|
| 201 | 201 | $last_lines = array(); |
| 202 | 202 | if (count($primary)) { |
| 203 | 203 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $last_lines[] = join(',', $unique_index); |
| 210 | 210 | } |
| 211 | 211 | if (count($last_lines)) { |
| 212 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 212 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 213 | 213 | } |
| 214 | 214 | return $this->exec($create_sql); |
| 215 | 215 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @param string $table |
| 233 | 233 | * @return array |
| 234 | 234 | */ |
| 235 | - public function describe_table($table, $schema='') |
|
| 235 | + public function describe_table($table, $schema = '') |
|
| 236 | 236 | { |
| 237 | 237 | $fields = array(); |
| 238 | 238 | if (!$schema) { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param string $table |
| 171 | 171 | * @param array $values |
| 172 | 172 | * @param array $fields |
| 173 | - * @return boolean |
|
| 173 | + * @return resource|null |
|
| 174 | 174 | */ |
| 175 | 175 | public function insert($table, $values, $fields=null) |
| 176 | 176 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param array $fields |
| 198 | 198 | * @param array $values |
| 199 | 199 | * @param string $where_condition |
| 200 | - * @return boolean |
|
| 200 | + * @return resource|null |
|
| 201 | 201 | */ |
| 202 | 202 | public function update($table, $fields, $values, $where_condition=null) |
| 203 | 203 | { |
@@ -298,7 +298,6 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * Efectua operaciones SQL sobre la base de datos |
| 300 | 300 | * Este método lo extienden los adapters |
| 301 | - * @param string $sql_query |
|
| 302 | 301 | * @return resource or false |
| 303 | 302 | */ |
| 304 | 303 | public function query($sql) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param string $orderBy |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - public function find($table, $where="1=1", $fields="*", $orderBy="1") |
|
| 66 | + public function find($table, $where = "1=1", $fields = "*", $orderBy = "1") |
|
| 67 | 67 | { |
| 68 | 68 | ActiveRecord::sql_item_sanitize($table); |
| 69 | 69 | ActiveRecord::sql_sanitize($fields); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param array $fields |
| 173 | 173 | * @return boolean |
| 174 | 174 | */ |
| 175 | - public function insert($table, $values, $fields=null) |
|
| 175 | + public function insert($table, $values, $fields = null) |
|
| 176 | 176 | { |
| 177 | 177 | //$insert_sql = ""; |
| 178 | 178 | if (is_array($values)) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $where_condition |
| 200 | 200 | * @return boolean |
| 201 | 201 | */ |
| 202 | - public function update($table, $fields, $values, $where_condition=null) |
|
| 202 | + public function update($table, $fields, $values, $where_condition = null) |
|
| 203 | 203 | { |
| 204 | 204 | $update_sql = "UPDATE $table SET "; |
| 205 | 205 | if (count($fields) != count($values)) { |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | $update_values[] = $field . ' = ' . $values[$i]; |
| 212 | 212 | $i++; |
| 213 | 213 | } |
| 214 | - $update_sql.= join(',', $update_values); |
|
| 214 | + $update_sql .= join(',', $update_values); |
|
| 215 | 215 | if ($where_condition != null) { |
| 216 | - $update_sql.= " WHERE $where_condition"; |
|
| 216 | + $update_sql .= " WHERE $where_condition"; |
|
| 217 | 217 | } |
| 218 | 218 | return $this->query($update_sql); |
| 219 | 219 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | /** |
| 662 | 662 | * Commit a Transaction |
| 663 | 663 | * |
| 664 | - * @return success |
|
| 664 | + * @return resource|null |
|
| 665 | 665 | */ |
| 666 | 666 | public function commit() |
| 667 | 667 | { |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | /** |
| 672 | 672 | * Rollback a Transaction |
| 673 | 673 | * |
| 674 | - * @return success |
|
| 674 | + * @return resource|null |
|
| 675 | 675 | */ |
| 676 | 676 | public function rollback() |
| 677 | 677 | { |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * Start a transaction in RDBM |
| 683 | 683 | * |
| 684 | - * @return success |
|
| 684 | + * @return resource|null |
|
| 685 | 685 | */ |
| 686 | 686 | public function begin() |
| 687 | 687 | { |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * Execute a SQL Statement directly |
| 726 | 726 | * |
| 727 | 727 | * @param string $sqlQuery |
| 728 | - * @return int affected |
|
| 728 | + * @return resource|null affected |
|
| 729 | 729 | */ |
| 730 | 730 | public function sql($sqlQuery) |
| 731 | 731 | { |
@@ -1217,7 +1217,6 @@ discard block |
||
| 1217 | 1217 | /** |
| 1218 | 1218 | * Creates a new Row in map table |
| 1219 | 1219 | * |
| 1220 | - * @param mixed $values |
|
| 1221 | 1220 | * @return boolean success |
| 1222 | 1221 | */ |
| 1223 | 1222 | public function create() |
@@ -1785,7 +1784,6 @@ discard block |
||
| 1785 | 1784 | /** |
| 1786 | 1785 | * Updates Data in the Relational Table |
| 1787 | 1786 | * |
| 1788 | - * @param mixed $values |
|
| 1789 | 1787 | * @return boolean|null sucess |
| 1790 | 1788 | */ |
| 1791 | 1789 | function update() |
@@ -1943,7 +1941,7 @@ discard block |
||
| 1943 | 1941 | * Delete All data from Relational Map Table |
| 1944 | 1942 | * |
| 1945 | 1943 | * @param string $conditions |
| 1946 | - * @return boolean |
|
| 1944 | + * @return resource|null |
|
| 1947 | 1945 | */ |
| 1948 | 1946 | public function delete_all($conditions = '') |
| 1949 | 1947 | { |
@@ -2478,7 +2478,7 @@ |
||
| 2478 | 2478 | /** |
| 2479 | 2479 | * Carga la clase |
| 2480 | 2480 | * */ |
| 2481 | - $model = Util::smallcase($Model); |
|
| 2481 | + $model = Util::smallcase($Model); |
|
| 2482 | 2482 | $file = APP_PATH . "models/$model.php"; |
| 2483 | 2483 | if (is_file($file)) { |
| 2484 | 2484 | include $file; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @param array $data |
| 260 | 260 | */ |
| 261 | - function __construct($data=null) |
|
| 261 | + function __construct($data = null) |
|
| 262 | 262 | { |
| 263 | 263 | if (!$this->source) { |
| 264 | 264 | $this->_model_name(); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | if ($data) { |
| 280 | 280 | if (!is_array($data)) $data = Util::getParams(func_get_args()); |
| 281 | - foreach($this->fields as $field) { |
|
| 281 | + foreach ($this->fields as $field) { |
|
| 282 | 282 | if (isset($data[$field])) { |
| 283 | 283 | $this->$field = $data[$field]; |
| 284 | 284 | } |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | } elseif (array_key_exists($mmodel, $this->_has_and_belongs_to_many)) { |
| 383 | 383 | $relation = $this->_has_and_belongs_to_many[$mmodel]; |
| 384 | 384 | $relation_model = self::get($relation->model); |
| 385 | - $source = ($this->schema ? "{$this->schema}." : NULL ) . $this->source; |
|
| 386 | - $relation_source = ($relation_model->schema ? "{$relation_model->schema}." : NULL ) . $relation_model->source; |
|
| 385 | + $source = ($this->schema ? "{$this->schema}." : NULL) . $this->source; |
|
| 386 | + $relation_source = ($relation_model->schema ? "{$relation_model->schema}." : NULL) . $relation_model->source; |
|
| 387 | 387 | /** |
| 388 | 388 | * Cargo atraves de que tabla se efectuara la relacion |
| 389 | 389 | * |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | } else { |
| 395 | 395 | $relation->through = "{$relation_source}_{$this->source}"; |
| 396 | 396 | } |
| 397 | - }else{ |
|
| 397 | + } else { |
|
| 398 | 398 | $through = explode('/', $relation->through); |
| 399 | 399 | $relation->through = end($through); |
| 400 | 400 | } |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | * @param $key |
| 635 | 635 | * @return array |
| 636 | 636 | */ |
| 637 | - public function get_alias($key=null) |
|
| 637 | + public function get_alias($key = null) |
|
| 638 | 638 | { |
| 639 | 639 | if ($key && array_key_exists($key, $this->alias)) { |
| 640 | 640 | return $this->alias[$key]; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | * @param string $key |
| 650 | 650 | * @param string $value |
| 651 | 651 | */ |
| 652 | - public function set_alias($key=null, $value=null) |
|
| 652 | + public function set_alias($key = null, $value = null) |
|
| 653 | 653 | { |
| 654 | 654 | if ($key && array_key_exists($key, $this->alias)) { |
| 655 | 655 | $this->alias[$key] = $value; |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | public function begin() |
| 687 | 687 | { |
| 688 | - $this->_connect();//(true); |
|
| 688 | + $this->_connect(); //(true); |
|
| 689 | 689 | return $this->db->begin(); |
| 690 | 690 | } |
| 691 | 691 | |
@@ -745,20 +745,20 @@ discard block |
||
| 745 | 745 | $what = Util::getParams(func_get_args()); |
| 746 | 746 | $select = "SELECT "; |
| 747 | 747 | if (isset($what['columns'])) { |
| 748 | - $select.= self::sql_sanitize($what['columns']); |
|
| 748 | + $select .= self::sql_sanitize($what['columns']); |
|
| 749 | 749 | } elseif (isset($what['distinct'])) { |
| 750 | - $select.= 'DISTINCT '; |
|
| 751 | - $select.= $what['distinct'] ? self::sql_sanitize($what['distinct']) : join(",", $this->fields); |
|
| 750 | + $select .= 'DISTINCT '; |
|
| 751 | + $select .= $what['distinct'] ? self::sql_sanitize($what['distinct']) : join(",", $this->fields); |
|
| 752 | 752 | } else { |
| 753 | - $select.= join(",", $this->fields); |
|
| 753 | + $select .= join(",", $this->fields); |
|
| 754 | 754 | } |
| 755 | 755 | if ($this->schema) { |
| 756 | - $select.= " FROM {$this->schema}.{$this->source}"; |
|
| 756 | + $select .= " FROM {$this->schema}.{$this->source}"; |
|
| 757 | 757 | } else { |
| 758 | - $select.= " FROM {$this->source}"; |
|
| 758 | + $select .= " FROM {$this->source}"; |
|
| 759 | 759 | } |
| 760 | 760 | $what['limit'] = 1; |
| 761 | - $select.= $this->convert_params_to_sql($what); |
|
| 761 | + $select .= $this->convert_params_to_sql($what); |
|
| 762 | 762 | $resp = false; |
| 763 | 763 | |
| 764 | 764 | $result = $this->db->fetch_one($select); |
@@ -789,19 +789,19 @@ discard block |
||
| 789 | 789 | $what = Util::getParams(func_get_args()); |
| 790 | 790 | $select = "SELECT "; |
| 791 | 791 | if (isset($what['columns'])) { |
| 792 | - $select.= $what['columns'] ? self::sql_sanitize($what['columns']) : join(",", $this->fields); |
|
| 792 | + $select .= $what['columns'] ? self::sql_sanitize($what['columns']) : join(",", $this->fields); |
|
| 793 | 793 | } elseif (isset($what['distinct'])) { |
| 794 | - $select.= 'DISTINCT '; |
|
| 795 | - $select.= $what['distinct'] ? self::sql_sanitize($what['distinct']) : join(",", $this->fields); |
|
| 794 | + $select .= 'DISTINCT '; |
|
| 795 | + $select .= $what['distinct'] ? self::sql_sanitize($what['distinct']) : join(",", $this->fields); |
|
| 796 | 796 | } else { |
| 797 | - $select.= join(",", $this->fields); |
|
| 797 | + $select .= join(",", $this->fields); |
|
| 798 | 798 | } |
| 799 | 799 | if ($this->schema) { |
| 800 | - $select.= " FROM {$this->schema}.{$this->source}"; |
|
| 800 | + $select .= " FROM {$this->schema}.{$this->source}"; |
|
| 801 | 801 | } else { |
| 802 | - $select.= " FROM {$this->source}"; |
|
| 802 | + $select .= " FROM {$this->source}"; |
|
| 803 | 803 | } |
| 804 | - $select.= $this->convert_params_to_sql($what); |
|
| 804 | + $select .= $this->convert_params_to_sql($what); |
|
| 805 | 805 | $results = array(); |
| 806 | 806 | $all_results = $this->db->in_query($select); |
| 807 | 807 | foreach ($all_results AS $result) { |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | self::sql_item_sanitize($this->primary_key[0]); |
| 846 | 846 | if (isset($what[0])) { |
| 847 | 847 | if (is_numeric($what[0])) { |
| 848 | - $what['conditions'] = "{$this->primary_key[0]} = ".(int)$what[0] ; |
|
| 848 | + $what['conditions'] = "{$this->primary_key[0]} = " . (int) $what[0]; |
|
| 849 | 849 | } else { |
| 850 | 850 | if ($what[0] == '') { |
| 851 | 851 | $what['conditions'] = "{$this->primary_key[0]} = ''"; |
@@ -856,27 +856,27 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | if (isset($what['join'])) { |
| 859 | - $select.= " {$what['join']}"; |
|
| 859 | + $select .= " {$what['join']}"; |
|
| 860 | 860 | } |
| 861 | 861 | if (isset($what['conditions'])) { |
| 862 | - $select.= " WHERE {$what['conditions']}"; |
|
| 862 | + $select .= " WHERE {$what['conditions']}"; |
|
| 863 | 863 | } |
| 864 | 864 | if (isset($what['group'])) { |
| 865 | - $select.= " GROUP BY {$what['group']}"; |
|
| 865 | + $select .= " GROUP BY {$what['group']}"; |
|
| 866 | 866 | } |
| 867 | 867 | if (isset($what['having'])) { |
| 868 | - $select.= " HAVING {$what['having']}"; |
|
| 868 | + $select .= " HAVING {$what['having']}"; |
|
| 869 | 869 | } |
| 870 | 870 | if (isset($what['order'])) { |
| 871 | 871 | self::sql_sanitize($what['order']); |
| 872 | - $select.= " ORDER BY {$what['order']}"; |
|
| 872 | + $select .= " ORDER BY {$what['order']}"; |
|
| 873 | 873 | } |
| 874 | 874 | $limit_args = array($select); |
| 875 | 875 | if (isset($what['limit'])) { |
| 876 | - array_push($limit_args, "limit: ".(int)$what['limit']); |
|
| 876 | + array_push($limit_args, "limit: " . (int) $what['limit']); |
|
| 877 | 877 | } |
| 878 | 878 | if (isset($what['offset'])) { |
| 879 | - array_push($limit_args, "offset: ".(int)$what['offset']); |
|
| 879 | + array_push($limit_args, "offset: " . (int) $what['offset']); |
|
| 880 | 880 | } |
| 881 | 881 | if (count($limit_args) > 1) { |
| 882 | 882 | $select = call_user_func_array(array($this, 'limit'), $limit_args); |
@@ -884,9 +884,9 @@ discard block |
||
| 884 | 884 | } else { |
| 885 | 885 | if (strlen($what)) { |
| 886 | 886 | if (is_numeric($what)) { |
| 887 | - $select.= "WHERE {$this->primary_key[0]} = ".(int)$what[0] ; |
|
| 887 | + $select .= "WHERE {$this->primary_key[0]} = " . (int) $what[0]; |
|
| 888 | 888 | } else { |
| 889 | - $select.= "WHERE $what"; |
|
| 889 | + $select .= "WHERE $what"; |
|
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | } |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | * Se elimina el de indice cero ya que por defecto convert_params_to_sql lo considera como una condicion en WHERE |
| 939 | 939 | */ |
| 940 | 940 | unset($what[0]); |
| 941 | - $select.= $this->convert_params_to_sql($what); |
|
| 941 | + $select .= $this->convert_params_to_sql($what); |
|
| 942 | 942 | $results = array(); |
| 943 | 943 | foreach ($this->db->fetch_all($select) as $result) { |
| 944 | 944 | $results[] = $result[0]; |
@@ -980,15 +980,15 @@ discard block |
||
| 980 | 980 | if (isset($what['distinct']) && $what['distinct']) { |
| 981 | 981 | if (isset($what['group'])) { |
| 982 | 982 | $select = "SELECT COUNT(*) FROM (SELECT DISTINCT {$what['distinct']} FROM $table "; |
| 983 | - $select.= $this->convert_params_to_sql($what); |
|
| 984 | - $select.= ') AS t '; |
|
| 983 | + $select .= $this->convert_params_to_sql($what); |
|
| 984 | + $select .= ') AS t '; |
|
| 985 | 985 | } else { |
| 986 | 986 | $select = "SELECT COUNT(DISTINCT {$what['distinct']}) FROM $table "; |
| 987 | - $select.= $this->convert_params_to_sql($what); |
|
| 987 | + $select .= $this->convert_params_to_sql($what); |
|
| 988 | 988 | } |
| 989 | 989 | } else { |
| 990 | 990 | $select = "SELECT COUNT(*) FROM $table "; |
| 991 | - $select.= $this->convert_params_to_sql($what); |
|
| 991 | + $select .= $this->convert_params_to_sql($what); |
|
| 992 | 992 | } |
| 993 | 993 | $num = $this->db->fetch_one($select); |
| 994 | 994 | return $num[0]; |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | $table = $this->source; |
| 1019 | 1019 | } |
| 1020 | 1020 | $select = "SELECT AVG({$what['column']}) FROM $table "; |
| 1021 | - $select.= $this->convert_params_to_sql($what); |
|
| 1021 | + $select .= $this->convert_params_to_sql($what); |
|
| 1022 | 1022 | $num = $this->db->fetch_one($select); |
| 1023 | 1023 | return $num[0]; |
| 1024 | 1024 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | $table = $this->source; |
| 1042 | 1042 | } |
| 1043 | 1043 | $select = "SELECT SUM({$what['column']}) FROM $table "; |
| 1044 | - $select.= $this->convert_params_to_sql($what); |
|
| 1044 | + $select .= $this->convert_params_to_sql($what); |
|
| 1045 | 1045 | $num = $this->db->fetch_one($select); |
| 1046 | 1046 | return $num[0]; |
| 1047 | 1047 | } |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | $table = $this->source; |
| 1071 | 1071 | } |
| 1072 | 1072 | $select = "SELECT MAX({$what['column']}) FROM $table "; |
| 1073 | - $select.= $this->convert_params_to_sql($what); |
|
| 1073 | + $select .= $this->convert_params_to_sql($what); |
|
| 1074 | 1074 | $num = $this->db->fetch_one($select); |
| 1075 | 1075 | return $num[0]; |
| 1076 | 1076 | } |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $table = $this->source; |
| 1100 | 1100 | } |
| 1101 | 1101 | $select = "SELECT MIN({$what['column']}) FROM $table "; |
| 1102 | - $select.= $this->convert_params_to_sql($what); |
|
| 1102 | + $select .= $this->convert_params_to_sql($what); |
|
| 1103 | 1103 | $num = $this->db->fetch_one($select); |
| 1104 | 1104 | return $num[0]; |
| 1105 | 1105 | } |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | * @param array $values array de valores a cargar |
| 1280 | 1280 | * @return boolean success |
| 1281 | 1281 | */ |
| 1282 | - public function save($values=null) |
|
| 1282 | + public function save($values = null) |
|
| 1283 | 1283 | { |
| 1284 | 1284 | if ($values) { |
| 1285 | 1285 | if (!is_array($values)) |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | } |
| 1645 | 1645 | if (isset($this->$np)) { |
| 1646 | 1646 | $fields[] = $np; |
| 1647 | - if (is_null($this->$np) || $this->$np == '' && $this->$np!='0') { |
|
| 1647 | + if (is_null($this->$np) || $this->$np == '' && $this->$np != '0') { |
|
| 1648 | 1648 | $values[] = 'NULL'; |
| 1649 | 1649 | } else { |
| 1650 | 1650 | /** |
@@ -2006,7 +2006,7 @@ discard block |
||
| 2006 | 2006 | * message: mensaje a mostrar |
| 2007 | 2007 | * field: nombre de campo a mostrar en el mensaje |
| 2008 | 2008 | */ |
| 2009 | - protected function validates_presence_of($field, $params=array()) |
|
| 2009 | + protected function validates_presence_of($field, $params = array()) |
|
| 2010 | 2010 | { |
| 2011 | 2011 | if (is_string($params)) |
| 2012 | 2012 | $params = Util::getParams(func_get_args()); |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | * too_long: mensaje a mostrar cuando sea muy largo |
| 2028 | 2028 | * field: nombre de campo a mostrar en el mensaje |
| 2029 | 2029 | */ |
| 2030 | - protected function validates_length_of($field, $max, $min=0, $params=array()) |
|
| 2030 | + protected function validates_length_of($field, $max, $min = 0, $params = array()) |
|
| 2031 | 2031 | { |
| 2032 | 2032 | if (is_string($params)) |
| 2033 | 2033 | $params = Util::getParams(func_get_args()); |
@@ -2047,7 +2047,7 @@ discard block |
||
| 2047 | 2047 | * message: mensaje a mostrar |
| 2048 | 2048 | * field: nombre del campo a mostrar en el mensaje |
| 2049 | 2049 | */ |
| 2050 | - protected function validates_inclusion_in($field, $list, $params=array()) |
|
| 2050 | + protected function validates_inclusion_in($field, $list, $params = array()) |
|
| 2051 | 2051 | { |
| 2052 | 2052 | if (is_string($params)) |
| 2053 | 2053 | $params = Util::getParams(func_get_args()); |
@@ -2066,7 +2066,7 @@ discard block |
||
| 2066 | 2066 | * message: mensaje a mostrar |
| 2067 | 2067 | * field: nombre del campo a mostrar en el mensaje |
| 2068 | 2068 | */ |
| 2069 | - protected function validates_exclusion_of($field, $list, $params=array()) |
|
| 2069 | + protected function validates_exclusion_of($field, $list, $params = array()) |
|
| 2070 | 2070 | { |
| 2071 | 2071 | if (is_string($params)) |
| 2072 | 2072 | $params = Util::getParams(func_get_args()); |
@@ -2085,7 +2085,7 @@ discard block |
||
| 2085 | 2085 | * message: mensaje a mostrar |
| 2086 | 2086 | * field: nombre del campo a mostrar en el mensaje |
| 2087 | 2087 | */ |
| 2088 | - protected function validates_format_of($field, $pattern, $params=array()) |
|
| 2088 | + protected function validates_format_of($field, $pattern, $params = array()) |
|
| 2089 | 2089 | { |
| 2090 | 2090 | if (is_string($params)) |
| 2091 | 2091 | $params = Util::getParams(func_get_args()); |
@@ -2103,7 +2103,7 @@ discard block |
||
| 2103 | 2103 | * message: mensaje a mostrar |
| 2104 | 2104 | * field: nombre del campo a mostrar en el mensaje |
| 2105 | 2105 | */ |
| 2106 | - protected function validates_numericality_of($field, $params=array()) |
|
| 2106 | + protected function validates_numericality_of($field, $params = array()) |
|
| 2107 | 2107 | { |
| 2108 | 2108 | if (is_string($params)) |
| 2109 | 2109 | $params = Util::getParams(func_get_args()); |
@@ -2120,7 +2120,7 @@ discard block |
||
| 2120 | 2120 | * message: mensaje a mostrar |
| 2121 | 2121 | * field: nombre del campo a mostrar en el mensaje |
| 2122 | 2122 | */ |
| 2123 | - protected function validates_email_in($field, $params=array()) |
|
| 2123 | + protected function validates_email_in($field, $params = array()) |
|
| 2124 | 2124 | { |
| 2125 | 2125 | if (is_string($params)) |
| 2126 | 2126 | $params = Util::getParams(func_get_args()); |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | * message: mensaje a mostrar |
| 2138 | 2138 | * field: nombre del campo a mostrar en el mensaje |
| 2139 | 2139 | */ |
| 2140 | - protected function validates_uniqueness_of($field, $params=array()) |
|
| 2140 | + protected function validates_uniqueness_of($field, $params = array()) |
|
| 2141 | 2141 | { |
| 2142 | 2142 | if (is_string($params)) |
| 2143 | 2143 | $params = Util::getParams(func_get_args()); |
@@ -2154,7 +2154,7 @@ discard block |
||
| 2154 | 2154 | * message: mensaje a mostrar |
| 2155 | 2155 | * field: nombre del campo a mostrar en el mensaje |
| 2156 | 2156 | */ |
| 2157 | - protected function validates_date_in($field, $params=array()) |
|
| 2157 | + protected function validates_date_in($field, $params = array()) |
|
| 2158 | 2158 | { |
| 2159 | 2159 | if (is_string($params)) |
| 2160 | 2160 | $params = Util::getParams(func_get_args()); |
@@ -277,7 +277,9 @@ discard block |
||
| 277 | 277 | $this->_connect(); |
| 278 | 278 | |
| 279 | 279 | if ($data) { |
| 280 | - if (!is_array($data)) $data = Util::getParams(func_get_args()); |
|
| 280 | + if (!is_array($data)) { |
|
| 281 | + $data = Util::getParams(func_get_args()); |
|
| 282 | + } |
|
| 281 | 283 | foreach($this->fields as $field) { |
| 282 | 284 | if (isset($data[$field])) { |
| 283 | 285 | $this->$field = $data[$field]; |
@@ -394,7 +396,7 @@ discard block |
||
| 394 | 396 | } else { |
| 395 | 397 | $relation->through = "{$relation_source}_{$this->source}"; |
| 396 | 398 | } |
| 397 | - }else{ |
|
| 399 | + } else{ |
|
| 398 | 400 | $through = explode('/', $relation->through); |
| 399 | 401 | $relation->through = end($through); |
| 400 | 402 | } |
@@ -593,8 +595,9 @@ discard block |
||
| 593 | 595 | if ($field['Key'] == 'PRI') { |
| 594 | 596 | $this->primary_key[] = $field['Field']; |
| 595 | 597 | $this->alias[$field['Field']] = 'Código'; |
| 596 | - } else |
|
| 597 | - $this->non_primary[] = $field['Field']; |
|
| 598 | + } else { |
|
| 599 | + $this->non_primary[] = $field['Field']; |
|
| 600 | + } |
|
| 598 | 601 | /** |
| 599 | 602 | * Si se indica que no puede ser nulo, pero se indica un |
| 600 | 603 | * valor por defecto, entonces no se incluye en la lista, ya que |
@@ -1282,8 +1285,9 @@ discard block |
||
| 1282 | 1285 | public function save($values=null) |
| 1283 | 1286 | { |
| 1284 | 1287 | if ($values) { |
| 1285 | - if (!is_array($values)) |
|
| 1286 | - $values = Util::getParams(func_get_args()); |
|
| 1288 | + if (!is_array($values)) { |
|
| 1289 | + $values = Util::getParams(func_get_args()); |
|
| 1290 | + } |
|
| 1287 | 1291 | foreach ($this->fields as $field) { |
| 1288 | 1292 | if (isset($values[$field])) { |
| 1289 | 1293 | $this->$field = $values[$field]; |
@@ -1345,8 +1349,9 @@ discard block |
||
| 1345 | 1349 | if (isset($this->_validates['presence_of'])) { |
| 1346 | 1350 | foreach ($this->_validates['presence_of'] as $f => $opt) { |
| 1347 | 1351 | if (isset($this->$f) && (is_null($this->$f) || $this->$f == '')) { |
| 1348 | - if (!$ex && $f == $this->primary_key[0]) |
|
| 1349 | - continue; |
|
| 1352 | + if (!$ex && $f == $this->primary_key[0]) { |
|
| 1353 | + continue; |
|
| 1354 | + } |
|
| 1350 | 1355 | if (isset($opt['message'])) { |
| 1351 | 1356 | Flash::error($opt['message']); |
| 1352 | 1357 | return false; |
@@ -1396,18 +1401,20 @@ discard block |
||
| 1396 | 1401 | $field = isset($opt['field']) ? $opt['field'] : $f; |
| 1397 | 1402 | |
| 1398 | 1403 | if (strlen($this->$f) < $opt['min']) { |
| 1399 | - if (isset($opt['too_short'])) |
|
| 1400 | - Flash::error($opt['too_short']); |
|
| 1401 | - else |
|
| 1402 | - Flash::error("Error: El campo $field debe tener como mínimo $opt[min] caracteres"); |
|
| 1404 | + if (isset($opt['too_short'])) { |
|
| 1405 | + Flash::error($opt['too_short']); |
|
| 1406 | + } else { |
|
| 1407 | + Flash::error("Error: El campo $field debe tener como mínimo $opt[min] caracteres"); |
|
| 1408 | + } |
|
| 1403 | 1409 | return false; |
| 1404 | 1410 | } |
| 1405 | 1411 | |
| 1406 | 1412 | if (strlen($this->$f) > $opt['max']) { |
| 1407 | - if (isset($opt['too_long'])) |
|
| 1408 | - Flash::error($opt['too_long']); |
|
| 1409 | - else |
|
| 1410 | - Flash::error("Error: El campo $field debe tener como máximo $opt[max] caracteres"); |
|
| 1413 | + if (isset($opt['too_long'])) { |
|
| 1414 | + Flash::error($opt['too_long']); |
|
| 1415 | + } else { |
|
| 1416 | + Flash::error("Error: El campo $field debe tener como máximo $opt[max] caracteres"); |
|
| 1417 | + } |
|
| 1411 | 1418 | return false; |
| 1412 | 1419 | } |
| 1413 | 1420 | } |
@@ -1569,8 +1576,9 @@ discard block |
||
| 1569 | 1576 | } else { |
| 1570 | 1577 | if (isset($this->after_validation_on_update)) { |
| 1571 | 1578 | $method = $this->after_validation_on_update; |
| 1572 | - if ($this->$method() == 'cancel') |
|
| 1573 | - return false; |
|
| 1579 | + if ($this->$method() == 'cancel') { |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1574 | 1582 | } |
| 1575 | 1583 | } |
| 1576 | 1584 | } |
@@ -2008,8 +2016,9 @@ discard block |
||
| 2008 | 2016 | */ |
| 2009 | 2017 | protected function validates_presence_of($field, $params=array()) |
| 2010 | 2018 | { |
| 2011 | - if (is_string($params)) |
|
| 2012 | - $params = Util::getParams(func_get_args()); |
|
| 2019 | + if (is_string($params)) { |
|
| 2020 | + $params = Util::getParams(func_get_args()); |
|
| 2021 | + } |
|
| 2013 | 2022 | |
| 2014 | 2023 | $this->_validates['presence_of'][$field] = $params; |
| 2015 | 2024 | } |
@@ -2029,8 +2038,9 @@ discard block |
||
| 2029 | 2038 | */ |
| 2030 | 2039 | protected function validates_length_of($field, $max, $min=0, $params=array()) |
| 2031 | 2040 | { |
| 2032 | - if (is_string($params)) |
|
| 2033 | - $params = Util::getParams(func_get_args()); |
|
| 2041 | + if (is_string($params)) { |
|
| 2042 | + $params = Util::getParams(func_get_args()); |
|
| 2043 | + } |
|
| 2034 | 2044 | |
| 2035 | 2045 | $this->_validates['length_of'][$field] = $params; |
| 2036 | 2046 | $this->_validates['length_of'][$field]['min'] = $min; |
@@ -2049,8 +2059,9 @@ discard block |
||
| 2049 | 2059 | */ |
| 2050 | 2060 | protected function validates_inclusion_in($field, $list, $params=array()) |
| 2051 | 2061 | { |
| 2052 | - if (is_string($params)) |
|
| 2053 | - $params = Util::getParams(func_get_args()); |
|
| 2062 | + if (is_string($params)) { |
|
| 2063 | + $params = Util::getParams(func_get_args()); |
|
| 2064 | + } |
|
| 2054 | 2065 | |
| 2055 | 2066 | $this->_validates['inclusion_in'][$field] = $params; |
| 2056 | 2067 | $this->_validates['inclusion_in'][$field]['list'] = $list; |
@@ -2068,8 +2079,9 @@ discard block |
||
| 2068 | 2079 | */ |
| 2069 | 2080 | protected function validates_exclusion_of($field, $list, $params=array()) |
| 2070 | 2081 | { |
| 2071 | - if (is_string($params)) |
|
| 2072 | - $params = Util::getParams(func_get_args()); |
|
| 2082 | + if (is_string($params)) { |
|
| 2083 | + $params = Util::getParams(func_get_args()); |
|
| 2084 | + } |
|
| 2073 | 2085 | |
| 2074 | 2086 | $this->_validates['exclusion_of'][$field] = $params; |
| 2075 | 2087 | $this->_validates['exclusion_of'][$field]['list'] = $list; |
@@ -2087,8 +2099,9 @@ discard block |
||
| 2087 | 2099 | */ |
| 2088 | 2100 | protected function validates_format_of($field, $pattern, $params=array()) |
| 2089 | 2101 | { |
| 2090 | - if (is_string($params)) |
|
| 2091 | - $params = Util::getParams(func_get_args()); |
|
| 2102 | + if (is_string($params)) { |
|
| 2103 | + $params = Util::getParams(func_get_args()); |
|
| 2104 | + } |
|
| 2092 | 2105 | |
| 2093 | 2106 | $this->_validates['format_of'][$field] = $params; |
| 2094 | 2107 | $this->_validates['format_of'][$field]['pattern'] = $pattern; |
@@ -2105,8 +2118,9 @@ discard block |
||
| 2105 | 2118 | */ |
| 2106 | 2119 | protected function validates_numericality_of($field, $params=array()) |
| 2107 | 2120 | { |
| 2108 | - if (is_string($params)) |
|
| 2109 | - $params = Util::getParams(func_get_args()); |
|
| 2121 | + if (is_string($params)) { |
|
| 2122 | + $params = Util::getParams(func_get_args()); |
|
| 2123 | + } |
|
| 2110 | 2124 | |
| 2111 | 2125 | $this->_validates['numericality_of'][$field] = $params; |
| 2112 | 2126 | } |
@@ -2122,8 +2136,9 @@ discard block |
||
| 2122 | 2136 | */ |
| 2123 | 2137 | protected function validates_email_in($field, $params=array()) |
| 2124 | 2138 | { |
| 2125 | - if (is_string($params)) |
|
| 2126 | - $params = Util::getParams(func_get_args()); |
|
| 2139 | + if (is_string($params)) { |
|
| 2140 | + $params = Util::getParams(func_get_args()); |
|
| 2141 | + } |
|
| 2127 | 2142 | |
| 2128 | 2143 | $this->_validates['email_in'][$field] = $params; |
| 2129 | 2144 | } |
@@ -2139,8 +2154,9 @@ discard block |
||
| 2139 | 2154 | */ |
| 2140 | 2155 | protected function validates_uniqueness_of($field, $params=array()) |
| 2141 | 2156 | { |
| 2142 | - if (is_string($params)) |
|
| 2143 | - $params = Util::getParams(func_get_args()); |
|
| 2157 | + if (is_string($params)) { |
|
| 2158 | + $params = Util::getParams(func_get_args()); |
|
| 2159 | + } |
|
| 2144 | 2160 | |
| 2145 | 2161 | $this->_validates['uniqueness_of'][$field] = $params; |
| 2146 | 2162 | } |
@@ -2156,8 +2172,9 @@ discard block |
||
| 2156 | 2172 | */ |
| 2157 | 2173 | protected function validates_date_in($field, $params=array()) |
| 2158 | 2174 | { |
| 2159 | - if (is_string($params)) |
|
| 2160 | - $params = Util::getParams(func_get_args()); |
|
| 2175 | + if (is_string($params)) { |
|
| 2176 | + $params = Util::getParams(func_get_args()); |
|
| 2177 | + } |
|
| 2161 | 2178 | |
| 2162 | 2179 | $this->_validates['date_in'][$field] = $params; |
| 2163 | 2180 | } |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | /** |
| 136 | 136 | * Asigna las extensiones de archivos permitidas |
| 137 | 137 | * |
| 138 | - * @param array|string $value lista de extensiones para archivos, si es string separado por | |
|
| 138 | + * @param string[] $value lista de extensiones para archivos, si es string separado por | |
|
| 139 | 139 | */ |
| 140 | 140 | public function setExtensions($value) { |
| 141 | 141 | if (!is_array($value)) { |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | /** |
| 40 | 40 | * Sube y actualiza la foto del usuario. |
| 41 | 41 | * |
| 42 | - * @return boolean | null |
|
| 42 | + * @return boolean|null | null |
|
| 43 | 43 | */ |
| 44 | 44 | public function updatePhoto() { |
| 45 | 45 | if ($photo = $this->uploadPhoto('photo')) { |