@@ -85,7 +85,7 @@ |
||
| 85 | 85 | $dbclass = "DbPdo{$config['type']}"; |
| 86 | 86 | $db_file = "$path/adapters/pdo/{$config['type']}.php"; |
| 87 | 87 | } else { |
| 88 | - if($config['type'] == 'mysql') $config['type'] = 'mysqli'; |
|
| 88 | + if ($config['type'] == 'mysql') $config['type'] = 'mysqli'; |
|
| 89 | 89 | $dbclass = "Db{$config['type']}"; |
| 90 | 90 | $db_file = "$path/adapters/{$config['type']}.php"; |
| 91 | 91 | } |
@@ -85,7 +85,9 @@ |
||
| 85 | 85 | $dbclass = "DbPdo{$config['type']}"; |
| 86 | 86 | $db_file = "$path/adapters/pdo/{$config['type']}.php"; |
| 87 | 87 | } else { |
| 88 | - if($config['type'] == 'mysql') $config['type'] = 'mysqli'; |
|
| 88 | + if($config['type'] == 'mysql') { |
|
| 89 | + $config['type'] = 'mysqli'; |
|
| 90 | + } |
|
| 89 | 91 | $dbclass = "Db{$config['type']}"; |
| 90 | 92 | $db_file = "$path/adapters/{$config['type']}.php"; |
| 91 | 93 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param int $opt |
| 197 | 197 | * @return array |
| 198 | 198 | */ |
| 199 | - public function fetch_array($pdo_statement=NULL, $opt='') |
|
| 199 | + public function fetch_array($pdo_statement = NULL, $opt = '') |
|
| 200 | 200 | { |
| 201 | 201 | if ($opt === '') { |
| 202 | 202 | $opt = self::DB_BOTH; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @deprecated |
| 236 | 236 | * @return int |
| 237 | 237 | */ |
| 238 | - public function num_rows($pdo_statement='') |
|
| 238 | + public function num_rows($pdo_statement = '') |
|
| 239 | 239 | { |
| 240 | 240 | if ($pdo_statement) { |
| 241 | 241 | $pdo = clone $pdo_statement; |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param resource $pdo_statement |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | - public function field_name($number, $pdo_statement=NULL) |
|
| 255 | + public function field_name($number, $pdo_statement = NULL) |
|
| 256 | 256 | { |
| 257 | 257 | if (!$this->pdo) { |
| 258 | 258 | throw new KumbiaException('No hay conexión para realizar esta acción'); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param PDOStatement $pdo_statement |
| 279 | 279 | * @return boolean |
| 280 | 280 | */ |
| 281 | - public function data_seek($number, $pdo_statement=NULL) |
|
| 281 | + public function data_seek($number, $pdo_statement = NULL) |
|
| 282 | 282 | { |
| 283 | 283 | return false; |
| 284 | 284 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @deprecated |
| 291 | 291 | * @return int |
| 292 | 292 | */ |
| 293 | - public function affected_rows($pdo_statement=NULL) |
|
| 293 | + public function affected_rows($pdo_statement = NULL) |
|
| 294 | 294 | { |
| 295 | 295 | if (!$this->pdo) { |
| 296 | 296 | throw new KumbiaException('No hay conexión para realizar esta acción'); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @return string |
| 317 | 317 | */ |
| 318 | - public function error($err='') |
|
| 318 | + public function error($err = '') |
|
| 319 | 319 | { |
| 320 | 320 | if ($this->pdo) { |
| 321 | 321 | $error = $this->pdo->errorInfo(); |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } else { |
| 324 | 324 | $error = ""; |
| 325 | 325 | } |
| 326 | - $this->last_error.= $error . " [" . $err . "]"; |
|
| 326 | + $this->last_error .= $error . " [" . $err . "]"; |
|
| 327 | 327 | if ($this->logger) { |
| 328 | 328 | Logger::error($this->last_error); |
| 329 | 329 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return int |
| 337 | 337 | */ |
| 338 | - public function no_error($number=0) |
|
| 338 | + public function no_error($number = 0) |
|
| 339 | 339 | { |
| 340 | 340 | if ($this->pdo) { |
| 341 | 341 | $error = $this->pdo->errorInfo(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | * |
| 350 | 350 | * @return string |
| 351 | 351 | */ |
| 352 | - public function last_insert_id($table='', $primary_key='') |
|
| 352 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 353 | 353 | { |
| 354 | 354 | return $this->pdo->lastInsertId(); |
| 355 | 355 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @param array $fields |
| 400 | 400 | * @return integer |
| 401 | 401 | */ |
| 402 | - public function insert($table, $values, $fields=null) |
|
| 402 | + public function insert($table, $values, $fields = null) |
|
| 403 | 403 | { |
| 404 | 404 | //$insert_sql = ""; |
| 405 | 405 | if (is_array($values)) { |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @param string $where_condition |
| 427 | 427 | * @return integer |
| 428 | 428 | */ |
| 429 | - public function update($table, $fields, $values, $where_condition=null) |
|
| 429 | + public function update($table, $fields, $values, $where_condition = null) |
|
| 430 | 430 | { |
| 431 | 431 | $update_sql = "UPDATE $table SET "; |
| 432 | 432 | if (count($fields) != count($values)) { |
@@ -438,9 +438,9 @@ discard block |
||
| 438 | 438 | $update_values[] = $field . ' = ' . $values[$i]; |
| 439 | 439 | $i++; |
| 440 | 440 | } |
| 441 | - $update_sql.= join(',', $update_values); |
|
| 441 | + $update_sql .= join(',', $update_values); |
|
| 442 | 442 | if ($where_condition != null) { |
| 443 | - $update_sql.= " WHERE $where_condition"; |
|
| 443 | + $update_sql .= " WHERE $where_condition"; |
|
| 444 | 444 | } |
| 445 | 445 | return $this->exec($update_sql); |
| 446 | 446 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param int $opt |
| 196 | 196 | * @return array |
| 197 | 197 | */ |
| 198 | - function fetch_array($resultQuery=NULL, $opt=OCI_BOTH) |
|
| 198 | + function fetch_array($resultQuery = NULL, $opt = OCI_BOTH) |
|
| 199 | 199 | { |
| 200 | 200 | |
| 201 | 201 | if (!$resultQuery) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * Devuelve el numero de filas de un select |
| 230 | 230 | */ |
| 231 | - function num_rows($resultQuery=NULL) |
|
| 231 | + function num_rows($resultQuery = NULL) |
|
| 232 | 232 | { |
| 233 | 233 | |
| 234 | 234 | if (!$resultQuery) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @param resource $resultQuery |
| 268 | 268 | * @return string |
| 269 | 269 | */ |
| 270 | - function field_name($number, $resultQuery=NULL) |
|
| 270 | + function field_name($number, $resultQuery = NULL) |
|
| 271 | 271 | { |
| 272 | 272 | |
| 273 | 273 | if (!$resultQuery) { |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param resource $resultQuery |
| 292 | 292 | * @return boolean |
| 293 | 293 | */ |
| 294 | - function data_seek($number, $resultQuery=NULL) |
|
| 294 | + function data_seek($number, $resultQuery = NULL) |
|
| 295 | 295 | { |
| 296 | 296 | if (!$resultQuery) { |
| 297 | 297 | $resultQuery = $this->last_result_query; |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @param resource $resultQuery |
| 326 | 326 | * @return int |
| 327 | 327 | */ |
| 328 | - function affected_rows($resultQuery=NULL) |
|
| 328 | + function affected_rows($resultQuery = NULL) |
|
| 329 | 329 | { |
| 330 | 330 | |
| 331 | 331 | if (!$resultQuery) { |
@@ -346,12 +346,12 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @return string |
| 348 | 348 | */ |
| 349 | - function error($err='') |
|
| 349 | + function error($err = '') |
|
| 350 | 350 | { |
| 351 | 351 | if (!$this->id_connection) { |
| 352 | 352 | $error = oci_error() ? oci_error() : "[Error Desconocido en Oracle]"; |
| 353 | 353 | if (is_array($error)) { |
| 354 | - $error['message'].=" > $err "; |
|
| 354 | + $error['message'] .= " > $err "; |
|
| 355 | 355 | return $error['message']; |
| 356 | 356 | } else { |
| 357 | 357 | //$error.=" $php_errormsg "; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | $error = oci_error($this->id_connection); |
| 362 | 362 | if ($error) { |
| 363 | - $error['message'].=" > $err "; |
|
| 363 | + $error['message'] .= " > $err "; |
|
| 364 | 364 | } else { |
| 365 | 365 | $error['message'] = $err; |
| 366 | 366 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @param string $table |
| 419 | 419 | * @return boolean |
| 420 | 420 | */ |
| 421 | - public function drop_table($table, $if_exists=true) |
|
| 421 | + public function drop_table($table, $if_exists = true) |
|
| 422 | 422 | { |
| 423 | 423 | if ($if_exists) { |
| 424 | 424 | if ($this->table_exists($table)) { |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param array $definition |
| 445 | 445 | * @return resource |
| 446 | 446 | */ |
| 447 | - public function create_table($table, $definition, $index=array()) |
|
| 447 | + public function create_table($table, $definition, $index = array()) |
|
| 448 | 448 | { |
| 449 | 449 | $create_sql = "CREATE TABLE $table ("; |
| 450 | 450 | if (!is_array($definition)) { |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 496 | 496 | } |
| 497 | - $create_sql.= join(',', $create_lines); |
|
| 497 | + $create_sql .= join(',', $create_lines); |
|
| 498 | 498 | $last_lines = array(); |
| 499 | 499 | if (count($primary)) { |
| 500 | 500 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | $last_lines[] = join(',', $unique_index); |
| 507 | 507 | } |
| 508 | 508 | if (count($last_lines)) { |
| 509 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 509 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 510 | 510 | } |
| 511 | 511 | return $this->query($create_sql); |
| 512 | 512 | } |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return int |
| 528 | 528 | */ |
| 529 | - public function last_insert_id($table='', $primary_key='') |
|
| 529 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 530 | 530 | { |
| 531 | 531 | if (!$this->id_connection) { |
| 532 | 532 | return false; |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @param string $table |
| 549 | 549 | * @return boolean |
| 550 | 550 | */ |
| 551 | - function table_exists($table, $schema='') |
|
| 551 | + function table_exists($table, $schema = '') |
|
| 552 | 552 | { |
| 553 | 553 | $num = $this->fetch_one("SELECT COUNT(*) FROM ALL_TABLES WHERE TABLE_NAME = '" . strtoupper($table) . "'"); |
| 554 | 554 | return $num[0]; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | * @param string $table |
| 561 | 561 | * @return array |
| 562 | 562 | */ |
| 563 | - public function describe_table($table, $schema='') |
|
| 563 | + public function describe_table($table, $schema = '') |
|
| 564 | 564 | { |
| 565 | 565 | /** |
| 566 | 566 | * Soporta schemas? |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @package Db |
| 27 | 27 | * @subpackage Adapters |
| 28 | 28 | */ |
| 29 | -class DbMsSQL extends DbBase implements DbBaseInterface { |
|
| 29 | +class DbMsSQL extends DbBase implements DbBaseInterface { |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Resource de la Conexión a MsSQL |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | * @param array $config |
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | - public function connect($config){ |
|
| 120 | - if(!extension_loaded('mssql')){ |
|
| 119 | + public function connect($config) { |
|
| 120 | + if (!extension_loaded('mssql')) { |
|
| 121 | 121 | throw new KumbiaException('Debe cargar la extensión de PHP llamada php_mssql'); |
| 122 | 122 | } |
| 123 | - if(!isset($config['port']) || !$config['port']) { |
|
| 123 | + if (!isset($config['port']) || !$config['port']) { |
|
| 124 | 124 | $config['port'] = 1433; |
| 125 | 125 | } |
| 126 | 126 | //if($this->id_connection = mssql_connect("{$config['host']},{$config['port']}", $config['username'], $config['password'], true)){ |
| 127 | - if($this->id_connection = mssql_connect($config['host'], $config['username'], $config['password'], true)){ |
|
| 128 | - if($config['name']!=='') { |
|
| 129 | - if(!mssql_select_db($config['name'], $this->id_connection)){ |
|
| 127 | + if ($this->id_connection = mssql_connect($config['host'], $config['username'], $config['password'], true)) { |
|
| 128 | + if ($config['name'] !== '') { |
|
| 129 | + if (!mssql_select_db($config['name'], $this->id_connection)) { |
|
| 130 | 130 | throw new KumbiaException($this->error()); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -141,25 +141,25 @@ discard block |
||
| 141 | 141 | * @param string $sql_query |
| 142 | 142 | * @return resource or false |
| 143 | 143 | */ |
| 144 | - public function query($sql_query){ |
|
| 144 | + public function query($sql_query) { |
|
| 145 | 145 | $this->debug($sql_query); |
| 146 | - if($this->logger){ |
|
| 146 | + if ($this->logger) { |
|
| 147 | 147 | Logger::debug($sql_query); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $this->last_query = $sql_query; |
| 151 | - if($result_query = mssql_query($sql_query, $this->id_connection)){ |
|
| 151 | + if ($result_query = mssql_query($sql_query, $this->id_connection)) { |
|
| 152 | 152 | $this->last_result_query = $result_query; |
| 153 | 153 | return $result_query; |
| 154 | - }else{ |
|
| 154 | + } else { |
|
| 155 | 155 | throw new KumbiaException($this->error(" al ejecutar <em>\"$sql_query\"</em>")); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | /** |
| 159 | 159 | * Cierra la Conexión al Motor de Base de datos |
| 160 | 160 | */ |
| 161 | - public function close(){ |
|
| 162 | - if($this->id_connection) { |
|
| 161 | + public function close() { |
|
| 162 | + if ($this->id_connection) { |
|
| 163 | 163 | return mssql_close(); |
| 164 | 164 | } |
| 165 | 165 | return false; |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | * @param int $opt |
| 172 | 172 | * @return array |
| 173 | 173 | */ |
| 174 | - public function fetch_array($result_query='', $opt=MSSQL_BOTH){ |
|
| 174 | + public function fetch_array($result_query = '', $opt = MSSQL_BOTH) { |
|
| 175 | 175 | |
| 176 | - if(!$result_query){ |
|
| 176 | + if (!$result_query) { |
|
| 177 | 177 | $result_query = $this->last_result_query; |
| 178 | - if(!$result_query){ |
|
| 178 | + if (!$result_query) { |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -186,21 +186,21 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @param array $config |
| 188 | 188 | */ |
| 189 | - public function __construct($config){ |
|
| 189 | + public function __construct($config) { |
|
| 190 | 190 | $this->connect($config); |
| 191 | 191 | } |
| 192 | 192 | /** |
| 193 | 193 | * Devuelve el número de filas de un select |
| 194 | 194 | */ |
| 195 | - public function num_rows($result_query=''){ |
|
| 195 | + public function num_rows($result_query = '') { |
|
| 196 | 196 | |
| 197 | - if(!$result_query){ |
|
| 197 | + if (!$result_query) { |
|
| 198 | 198 | $result_query = $this->last_result_query; |
| 199 | - if(!$result_query){ |
|
| 199 | + if (!$result_query) { |
|
| 200 | 200 | return false; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | - if(($number_rows = mssql_num_rows($result_query))!==false){ |
|
| 203 | + if (($number_rows = mssql_num_rows($result_query)) !== false) { |
|
| 204 | 204 | return $number_rows; |
| 205 | 205 | } else { |
| 206 | 206 | throw new KumbiaException($this->error()); |
@@ -214,15 +214,15 @@ 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 | - if(!$result_query){ |
|
| 219 | + if (!$result_query) { |
|
| 220 | 220 | $result_query = $this->last_result_query; |
| 221 | - if(!$result_query){ |
|
| 221 | + if (!$result_query) { |
|
| 222 | 222 | return false; |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - if(($fieldName = mssql_field_name($result_query, $number))!==false){ |
|
| 225 | + if (($fieldName = mssql_field_name($result_query, $number)) !== false) { |
|
| 226 | 226 | return $fieldName; |
| 227 | 227 | } else { |
| 228 | 228 | throw new KumbiaException($this->error()); |
@@ -235,14 +235,14 @@ discard block |
||
| 235 | 235 | * @param resource $result_query |
| 236 | 236 | * @return boolean |
| 237 | 237 | */ |
| 238 | - public function data_seek($number, $result_query=''){ |
|
| 239 | - if(!$result_query){ |
|
| 238 | + public function data_seek($number, $result_query = '') { |
|
| 239 | + if (!$result_query) { |
|
| 240 | 240 | $result_query = $this->last_result_query; |
| 241 | - if(!$result_query){ |
|
| 241 | + if (!$result_query) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | - if(($success = mssql_data_seek($result_query, $number))!==false){ |
|
| 245 | + if (($success = mssql_data_seek($result_query, $number)) !== false) { |
|
| 246 | 246 | return $success; |
| 247 | 247 | } else { |
| 248 | 248 | throw new KumbiaException($this->error()); |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * @param resource $result_query |
| 256 | 256 | * @return int |
| 257 | 257 | */ |
| 258 | - public function affected_rows($result_query=''){ |
|
| 259 | - if(($numberRows = mssql_affected_rows())!==false){ |
|
| 258 | + public function affected_rows($result_query = '') { |
|
| 259 | + if (($numberRows = mssql_affected_rows()) !== false) { |
|
| 260 | 260 | return $numberRows; |
| 261 | 261 | } else { |
| 262 | 262 | throw new KumbiaException($this->error()); |
@@ -268,17 +268,17 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @return string |
| 270 | 270 | */ |
| 271 | - public function error($err=''){ |
|
| 272 | - if(!$this->id_connection){ |
|
| 271 | + public function error($err = '') { |
|
| 272 | + if (!$this->id_connection) { |
|
| 273 | 273 | $this->last_error = mssql_get_last_message() ? mssql_get_last_message() : "[Error Desconocido en MsSQL: $err]"; |
| 274 | - if($this->logger){ |
|
| 274 | + if ($this->logger) { |
|
| 275 | 275 | Logger::error($this->last_error); |
| 276 | 276 | } |
| 277 | 277 | return $this->last_error; |
| 278 | 278 | } |
| 279 | 279 | $this->last_error = mssql_get_last_message() ? mssql_get_last_message() : "[Error Desconocido en MsSQL: $err]"; |
| 280 | - $this->last_error.= $err; |
|
| 281 | - if($this->logger){ |
|
| 280 | + $this->last_error .= $err; |
|
| 281 | + if ($this->logger) { |
|
| 282 | 282 | Logger::error($this->last_error); |
| 283 | 283 | } |
| 284 | 284 | return $this->last_error; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return int |
| 290 | 290 | */ |
| 291 | - public function no_error(){ |
|
| 291 | + public function no_error() { |
|
| 292 | 292 | return mssql_errno(); |
| 293 | 293 | } |
| 294 | 294 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return int |
| 298 | 298 | */ |
| 299 | - public function last_insert_id($table='', $primary_key=''){ |
|
| 299 | + public function last_insert_id($table = '', $primary_key = '') { |
|
| 300 | 300 | |
| 301 | 301 | //$id = false; |
| 302 | 302 | $result = mssql_query("select max({$primary_key}) from $table"); |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | * @param string $table |
| 313 | 313 | * @return boolean |
| 314 | 314 | */ |
| 315 | - public function table_exists($table, $schema=''){ |
|
| 315 | + public function table_exists($table, $schema = '') { |
|
| 316 | 316 | $table = addslashes("$table"); |
| 317 | - if($schema==''){ |
|
| 317 | + if ($schema == '') { |
|
| 318 | 318 | $num = $this->fetch_one("SELECT COUNT(*) FROM |
| 319 | 319 | INFORMATION_SCHEMA.TABLES |
| 320 | 320 | WHERE TABLE_NAME = '$table'"); |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | * @param string $sql consulta sql |
| 334 | 334 | * @return string |
| 335 | 335 | */ |
| 336 | - public function limit($sql){ |
|
| 336 | + public function limit($sql) { |
|
| 337 | 337 | $params = Util::getParams(func_get_args()); |
| 338 | 338 | |
| 339 | 339 | //TODO: añadirle el offset |
| 340 | - if(isset($params['limit'])){ |
|
| 340 | + if (isset($params['limit'])) { |
|
| 341 | 341 | $sql = str_ireplace("SELECT ", "SELECT TOP $params[limit] ", $sql); |
| 342 | 342 | } |
| 343 | 343 | return $sql; |
@@ -349,8 +349,8 @@ discard block |
||
| 349 | 349 | * @param string $table |
| 350 | 350 | * @return resource |
| 351 | 351 | */ |
| 352 | - public function drop_table($table, $if_exists=true){ |
|
| 353 | - if($if_exists){ |
|
| 352 | + public function drop_table($table, $if_exists = true) { |
|
| 353 | + if ($if_exists) { |
|
| 354 | 354 | $sql = "IF EXISTS(SELECT TABLE_NAME FROM |
| 355 | 355 | INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '$table') |
| 356 | 356 | DROP TABLE $table;"; |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * |
| 365 | 365 | * @return array |
| 366 | 366 | */ |
| 367 | - public function list_tables(){ |
|
| 367 | + public function list_tables() { |
|
| 368 | 368 | return $this->fetch_all("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES"); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -388,20 +388,20 @@ discard block |
||
| 388 | 388 | return $this->fetch_all($sql); |
| 389 | 389 | } |
| 390 | 390 | */ |
| 391 | - public function describe_table($table, $schema=''){ |
|
| 391 | + public function describe_table($table, $schema = '') { |
|
| 392 | 392 | $describeTable = $this->fetch_all("exec sp_columns @table_name = '$table'"); |
| 393 | 393 | $finalDescribe = array(); |
| 394 | - foreach($describeTable as $field){ |
|
| 394 | + foreach ($describeTable as $field) { |
|
| 395 | 395 | $finalDescribe[] = array( |
| 396 | 396 | 'Field' => $field['COLUMN_NAME'], |
| 397 | - 'Type' => $field['LENGTH'] ? $field['TYPE_NAME'] : $field['TYPE_NAME'].'('.$field['LENGTH'].')', |
|
| 397 | + 'Type' => $field['LENGTH'] ? $field['TYPE_NAME'] : $field['TYPE_NAME'] . '(' . $field['LENGTH'] . ')', |
|
| 398 | 398 | 'Null' => $field['NULLABLE'] == 1 ? 'YES' : 'NO' |
| 399 | 399 | ); |
| 400 | 400 | } |
| 401 | 401 | $describeKeys = $this->fetch_all("exec sp_pkeys @table_name = '$table'"); |
| 402 | - foreach($describeKeys as $field){ |
|
| 403 | - for($i=0;$i<=count($finalDescribe)-1;++$i){ |
|
| 404 | - if($finalDescribe[$i]['Field']==$field['COLUMN_NAME']){ |
|
| 402 | + foreach ($describeKeys as $field) { |
|
| 403 | + for ($i = 0; $i <= count($finalDescribe) - 1; ++$i) { |
|
| 404 | + if ($finalDescribe[$i]['Field'] == $field['COLUMN_NAME']) { |
|
| 405 | 405 | $finalDescribe[$i]['Key'] = 'PRI'; |
| 406 | 406 | } else { |
| 407 | 407 | $finalDescribe[$i]['Key'] = ""; |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | * @param resource $result_query |
| 419 | 419 | * @return object |
| 420 | 420 | */ |
| 421 | - public function fetch_object($result_query = NULL){ |
|
| 422 | - if(!$result_query){ |
|
| 421 | + public function fetch_object($result_query = NULL) { |
|
| 422 | + if (!$result_query) { |
|
| 423 | 423 | $result_query = $this->last_result_query; |
| 424 | 424 | } |
| 425 | 425 | return mssql_fetch_object($result_query); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - public function create_table ($table, $definition, $index = array()){ |
|
| 428 | + public function create_table($table, $definition, $index = array()) { |
|
| 429 | 429 | |
| 430 | 430 | } |
| 431 | 431 | } |
@@ -151,7 +151,7 @@ |
||
| 151 | 151 | if($result_query = mssql_query($sql_query, $this->id_connection)){ |
| 152 | 152 | $this->last_result_query = $result_query; |
| 153 | 153 | return $result_query; |
| 154 | - }else{ |
|
| 154 | + } else{ |
|
| 155 | 155 | throw new KumbiaException($this->error(" al ejecutar <em>\"$sql_query\"</em>")); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param int $opt |
| 175 | 175 | * @return array |
| 176 | 176 | */ |
| 177 | - function fetch_array($resultQuery=NULL, $opt=PGSQL_BOTH) |
|
| 177 | + function fetch_array($resultQuery = NULL, $opt = PGSQL_BOTH) |
|
| 178 | 178 | { |
| 179 | 179 | |
| 180 | 180 | if (!$resultQuery) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | /** |
| 200 | 200 | * Devuelve el numero de filas de un select |
| 201 | 201 | */ |
| 202 | - function num_rows($resultQuery=NULL) |
|
| 202 | + function num_rows($resultQuery = NULL) |
|
| 203 | 203 | { |
| 204 | 204 | |
| 205 | 205 | if (!$resultQuery) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param resource $resultQuery |
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | - function field_name($number, $resultQuery=NULL) |
|
| 225 | + function field_name($number, $resultQuery = NULL) |
|
| 226 | 226 | { |
| 227 | 227 | |
| 228 | 228 | if (!$resultQuery) { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param resource $resultQuery |
| 246 | 246 | * @return boolean |
| 247 | 247 | */ |
| 248 | - function data_seek($number, $resultQuery=NULL) |
|
| 248 | + function data_seek($number, $resultQuery = NULL) |
|
| 249 | 249 | { |
| 250 | 250 | if (!$resultQuery) { |
| 251 | 251 | $resultQuery = $this->last_result_query; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param resource $resultQuery |
| 267 | 267 | * @return int |
| 268 | 268 | */ |
| 269 | - function affected_rows($resultQuery=NULL) |
|
| 269 | + function affected_rows($resultQuery = NULL) |
|
| 270 | 270 | { |
| 271 | 271 | |
| 272 | 272 | if (!$resultQuery) { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return string |
| 289 | 289 | */ |
| 290 | - function error($err='') |
|
| 290 | + function error($err = '') |
|
| 291 | 291 | { |
| 292 | 292 | if (!$this->id_connection) { |
| 293 | 293 | $this->last_error = @pg_last_error() ? @pg_last_error() . $err : "[Error Desconocido en PostgreSQL \"$err\"]"; |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | return $this->last_error; |
| 298 | 298 | } |
| 299 | 299 | $this->last_error = @pg_last_error() ? @pg_last_error() . $err : "[Error Desconocido en PostgreSQL: $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 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @return int |
| 322 | 322 | */ |
| 323 | - public function last_insert_id($table='', $primary_key='') |
|
| 323 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 324 | 324 | { |
| 325 | 325 | |
| 326 | 326 | $last_id = $this->fetch_one("SELECT CURRVAL('{$table}_{$primary_key}_seq')"); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @param string $table |
| 334 | 334 | * @return boolean |
| 335 | 335 | */ |
| 336 | - function table_exists($table, $schema='') |
|
| 336 | + function table_exists($table, $schema = '') |
|
| 337 | 337 | { |
| 338 | 338 | $table = addslashes(strtolower($table)); |
| 339 | 339 | if (strpos($table, ".")) { |
@@ -360,11 +360,11 @@ discard block |
||
| 360 | 360 | $sql_new = $sql; |
| 361 | 361 | |
| 362 | 362 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 363 | - $sql_new.=" LIMIT $params[limit]"; |
|
| 363 | + $sql_new .= " LIMIT $params[limit]"; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 367 | - $sql_new.=" OFFSET $params[offset]"; |
|
| 367 | + $sql_new .= " OFFSET $params[offset]"; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return $sql_new; |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * @param string $table |
| 377 | 377 | * @return boolean |
| 378 | 378 | */ |
| 379 | - public function drop_table($table, $if_exists=true) |
|
| 379 | + public function drop_table($table, $if_exists = true) |
|
| 380 | 380 | { |
| 381 | 381 | if ($if_exists) { |
| 382 | 382 | if ($this->table_exists($table)) { |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @param array $definition |
| 403 | 403 | * @return resource |
| 404 | 404 | */ |
| 405 | - public function create_table($table, $definition, $index=array()) |
|
| 405 | + public function create_table($table, $definition, $index = array()) |
|
| 406 | 406 | { |
| 407 | 407 | $create_sql = "CREATE TABLE $table ("; |
| 408 | 408 | if (!is_array($definition)) { |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 454 | 454 | } |
| 455 | - $create_sql.= join(',', $create_lines); |
|
| 455 | + $create_sql .= join(',', $create_lines); |
|
| 456 | 456 | $last_lines = array(); |
| 457 | 457 | if (count($primary)) { |
| 458 | 458 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | $last_lines[] = join(',', $unique_index); |
| 465 | 465 | } |
| 466 | 466 | if (count($last_lines)) { |
| 467 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 467 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 468 | 468 | } |
| 469 | 469 | return $this->query($create_sql); |
| 470 | 470 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @param string $table |
| 494 | 494 | * @return array |
| 495 | 495 | */ |
| 496 | - public function describe_table($table, $schema='') |
|
| 496 | + public function describe_table($table, $schema = '') |
|
| 497 | 497 | { |
| 498 | 498 | $describe = $this->fetch_all("SELECT a.attname AS Field, t.typname AS Type, |
| 499 | 499 | CASE WHEN attnotnull=false THEN 'YES' ELSE 'NO' END AS Null, |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | * @param string $class clase de objeto |
| 524 | 524 | * @return object |
| 525 | 525 | */ |
| 526 | - public function fetch_object($query_result=null, $class='stdClass') |
|
| 526 | + public function fetch_object($query_result = null, $class = 'stdClass') |
|
| 527 | 527 | { |
| 528 | 528 | if (!$query_result) { |
| 529 | 529 | $query_result = $this->last_result_query; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $table |
| 93 | 93 | * @return boolean |
| 94 | 94 | */ |
| 95 | - public function table_exists($table, $schema='') |
|
| 95 | + public function table_exists($table, $schema = '') |
|
| 96 | 96 | { |
| 97 | 97 | $table = addslashes("$table"); |
| 98 | 98 | $num = $this->fetch_one("SELECT COUNT(*) FROM sysobjects WHERE type = 'U' AND name = '$table'"); |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($number) . ' ', $sql); |
| 120 | 120 | $sql = 'SELECT * FROM (SELECT TOP ' . $number . ' * FROM (' . $sql . ') AS itable'; |
| 121 | 121 | if ($orderby !== false) { |
| 122 | - $sql.= ' ORDER BY ' . $order . ' '; |
|
| 123 | - $sql.= ( stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; |
|
| 122 | + $sql .= ' ORDER BY ' . $order . ' '; |
|
| 123 | + $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; |
|
| 124 | 124 | } |
| 125 | - $sql.= ') AS otable'; |
|
| 125 | + $sql .= ') AS otable'; |
|
| 126 | 126 | if ($orderby !== false) { |
| 127 | - $sql.=' ORDER BY ' . $order . ' ' . $sort; |
|
| 127 | + $sql .= ' ORDER BY ' . $order . ' ' . $sort; |
|
| 128 | 128 | } |
| 129 | 129 | return $sql; |
| 130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $table |
| 136 | 136 | * @return boolean |
| 137 | 137 | */ |
| 138 | - public function drop_table($table, $if_exists=true) |
|
| 138 | + public function drop_table($table, $if_exists = true) |
|
| 139 | 139 | { |
| 140 | 140 | if ($if_exists) { |
| 141 | 141 | if ($this->table_exists($table)) { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param array $definition |
| 162 | 162 | * @return boolean |
| 163 | 163 | */ |
| 164 | - public function create_table($table, $definition, $index=array()) |
|
| 164 | + public function create_table($table, $definition, $index = array()) |
|
| 165 | 165 | { |
| 166 | 166 | $create_sql = "CREATE TABLE $table ("; |
| 167 | 167 | if (!is_array($definition)) { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 213 | 213 | } |
| 214 | - $create_sql.= join(',', $create_lines); |
|
| 214 | + $create_sql .= join(',', $create_lines); |
|
| 215 | 215 | $last_lines = array(); |
| 216 | 216 | if (count($primary)) { |
| 217 | 217 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $last_lines[] = join(',', $unique_index); |
| 224 | 224 | } |
| 225 | 225 | if (count($last_lines)) { |
| 226 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 226 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 227 | 227 | } |
| 228 | 228 | return $this->query($create_sql); |
| 229 | 229 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $table |
| 245 | 245 | * @return array |
| 246 | 246 | */ |
| 247 | - public function describe_table($table, $schema='') |
|
| 247 | + public function describe_table($table, $schema = '') |
|
| 248 | 248 | { |
| 249 | 249 | $describe_table = $this->fetch_all("exec sp_columns @table_name = '$table'"); |
| 250 | 250 | $final_describe = array(); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return integer |
| 275 | 275 | */ |
| 276 | - public function last_insert_id($table='', $primary_key='') |
|
| 276 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 277 | 277 | { |
| 278 | 278 | /** |
| 279 | 279 | * Porque no funciona SELECT SCOPE_IDENTITY()? |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $table |
| 96 | 96 | * @return boolean |
| 97 | 97 | */ |
| 98 | - public function table_exists($table, $schema='') |
|
| 98 | + public function table_exists($table, $schema = '') |
|
| 99 | 99 | { |
| 100 | 100 | $table = addslashes("$table"); |
| 101 | 101 | if ($schema == '') { |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | $sql_new = $sql; |
| 120 | 120 | |
| 121 | 121 | if (isset($params['limit']) && is_numeric($params['limit'])) { |
| 122 | - $sql_new.=" LIMIT $params[limit]"; |
|
| 122 | + $sql_new .= " LIMIT $params[limit]"; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if (isset($params['offset']) && is_numeric($params['offset'])) { |
| 126 | - $sql_new.=" OFFSET $params[offset]"; |
|
| 126 | + $sql_new .= " OFFSET $params[offset]"; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return $sql_new; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $table |
| 136 | 136 | * @return boolean |
| 137 | 137 | */ |
| 138 | - public function drop_table($table, $if_exists=true) |
|
| 138 | + public function drop_table($table, $if_exists = true) |
|
| 139 | 139 | { |
| 140 | 140 | if ($if_exists) { |
| 141 | 141 | return $this->query("DROP TABLE IF EXISTS $table"); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param array $definition |
| 158 | 158 | * @return boolean |
| 159 | 159 | */ |
| 160 | - public function create_table($table, $definition, $index=array()) |
|
| 160 | + public function create_table($table, $definition, $index = array()) |
|
| 161 | 161 | { |
| 162 | 162 | $create_sql = "CREATE TABLE $table ("; |
| 163 | 163 | if (!is_array($definition)) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | $create_lines[] = "`$field` " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 209 | 209 | } |
| 210 | - $create_sql.= join(',', $create_lines); |
|
| 210 | + $create_sql .= join(',', $create_lines); |
|
| 211 | 211 | $last_lines = array(); |
| 212 | 212 | if (count($primary)) { |
| 213 | 213 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $last_lines[] = join(',', $unique_index); |
| 220 | 220 | } |
| 221 | 221 | if (count($last_lines)) { |
| 222 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 222 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 223 | 223 | } |
| 224 | 224 | return $this->query($create_sql); |
| 225 | 225 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param string $table |
| 241 | 241 | * @return array |
| 242 | 242 | */ |
| 243 | - public function describe_table($table, $schema='') |
|
| 243 | + public function describe_table($table, $schema = '') |
|
| 244 | 244 | { |
| 245 | 245 | if ($schema == '') { |
| 246 | 246 | $describe = $this->fetch_all("DESCRIBE `$table`"); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * @param string $table |
| 118 | 118 | * @return boolean |
| 119 | 119 | */ |
| 120 | - public function drop_table($table, $if_exists=true) |
|
| 120 | + public function drop_table($table, $if_exists = true) |
|
| 121 | 121 | { |
| 122 | 122 | if ($if_exists) { |
| 123 | 123 | if ($this->table_exists($table)) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param array $definition |
| 143 | 143 | * @return boolean |
| 144 | 144 | */ |
| 145 | - public function create_table($table, $definition, $index=array()) |
|
| 145 | + public function create_table($table, $definition, $index = array()) |
|
| 146 | 146 | { |
| 147 | 147 | $create_sql = "CREATE TABLE $table ("; |
| 148 | 148 | if (!is_array($definition)) { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 194 | 194 | } |
| 195 | - $create_sql.= join(',', $create_lines); |
|
| 195 | + $create_sql .= join(',', $create_lines); |
|
| 196 | 196 | $last_lines = array(); |
| 197 | 197 | if (count($primary)) { |
| 198 | 198 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $last_lines[] = join(',', $unique_index); |
| 205 | 205 | } |
| 206 | 206 | if (count($last_lines)) { |
| 207 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 207 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 208 | 208 | } |
| 209 | 209 | return $this->query($create_sql); |
| 210 | 210 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return integer |
| 226 | 226 | */ |
| 227 | - public function last_insert_id($table='', $primary_key='') |
|
| 227 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 228 | 228 | { |
| 229 | 229 | /** |
| 230 | 230 | * Oracle No soporta columnas autonuméricas |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @param string $table |
| 244 | 244 | * @return boolean |
| 245 | 245 | */ |
| 246 | - function table_exists($table, $schema='') |
|
| 246 | + function table_exists($table, $schema = '') |
|
| 247 | 247 | { |
| 248 | 248 | $num = $this->fetch_one("SELECT COUNT(*) FROM ALL_TABLES WHERE TABLE_NAME = '" . strtoupper($table) . "'"); |
| 249 | 249 | return $num[0]; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param string $table |
| 256 | 256 | * @return array |
| 257 | 257 | */ |
| 258 | - public function describe_table($table, $schema='') |
|
| 258 | + public function describe_table($table, $schema = '') |
|
| 259 | 259 | { |
| 260 | 260 | /** |
| 261 | 261 | * Soporta schemas? |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $table |
| 93 | 93 | * @return boolean |
| 94 | 94 | */ |
| 95 | - public function table_exists($table, $schema='') |
|
| 95 | + public function table_exists($table, $schema = '') |
|
| 96 | 96 | { |
| 97 | 97 | $table = addslashes("$table"); |
| 98 | 98 | $num = $this->fetch_one("SELECT COUNT(*) FROM sysobjects WHERE type = 'U' AND name = '$table'"); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $params = Util::getParams(func_get_args()); |
| 111 | 111 | |
| 112 | - if(!isset($params['offset']) && isset($params['limit'])){ |
|
| 112 | + if (!isset($params['offset']) && isset($params['limit'])) { |
|
| 113 | 113 | return str_ireplace("SELECT ", "SELECT TOP $params[limit] ", $sql); |
| 114 | 114 | } |
| 115 | 115 | $orderby = stristr($sql, 'ORDER BY'); |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $params[offset] . ' ', $sql); |
| 122 | 122 | $sql = 'SELECT * FROM (SELECT TOP ' . $params[limit] . ' * FROM (' . $sql . ') AS itable'; |
| 123 | 123 | if ($orderby !== false) { |
| 124 | - $sql.= ' ORDER BY ' . $order . ' '; |
|
| 125 | - $sql.= ( stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; |
|
| 124 | + $sql .= ' ORDER BY ' . $order . ' '; |
|
| 125 | + $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC'; |
|
| 126 | 126 | } |
| 127 | - $sql.= ') AS otable'; |
|
| 127 | + $sql .= ') AS otable'; |
|
| 128 | 128 | if ($orderby !== false) { |
| 129 | - $sql.=' ORDER BY ' . $order . ' ' . $sort; |
|
| 129 | + $sql .= ' ORDER BY ' . $order . ' ' . $sort; |
|
| 130 | 130 | } |
| 131 | 131 | return $sql; |
| 132 | 132 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $table |
| 138 | 138 | * @return boolean |
| 139 | 139 | */ |
| 140 | - public function drop_table($table, $if_exists=true) |
|
| 140 | + public function drop_table($table, $if_exists = true) |
|
| 141 | 141 | { |
| 142 | 142 | if ($if_exists) { |
| 143 | 143 | if ($this->table_exists($table)) { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param array $definition |
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | - public function create_table($table, $definition, $index=array()) |
|
| 166 | + public function create_table($table, $definition, $index = array()) |
|
| 167 | 167 | { |
| 168 | 168 | $create_sql = "CREATE TABLE $table ("; |
| 169 | 169 | if (!is_array($definition)) { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | $create_lines[] = "$field " . $field_def['type'] . $size . ' ' . $not_null . ' ' . $extra; |
| 215 | 215 | } |
| 216 | - $create_sql.= join(',', $create_lines); |
|
| 216 | + $create_sql .= join(',', $create_lines); |
|
| 217 | 217 | $last_lines = array(); |
| 218 | 218 | if (count($primary)) { |
| 219 | 219 | $last_lines[] = 'PRIMARY KEY(' . join(",", $primary) . ')'; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $last_lines[] = join(',', $unique_index); |
| 226 | 226 | } |
| 227 | 227 | if (count($last_lines)) { |
| 228 | - $create_sql.= ',' . join(',', $last_lines) . ')'; |
|
| 228 | + $create_sql .= ',' . join(',', $last_lines) . ')'; |
|
| 229 | 229 | } |
| 230 | 230 | return $this->query($create_sql); |
| 231 | 231 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param string $table |
| 247 | 247 | * @return array |
| 248 | 248 | */ |
| 249 | - public function describe_table($table, $schema='') |
|
| 249 | + public function describe_table($table, $schema = '') |
|
| 250 | 250 | { |
| 251 | 251 | $describe_table = $this->fetch_all("exec sp_columns @table_name = '$table'"); |
| 252 | 252 | $final_describe = array(); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return integer |
| 277 | 277 | */ |
| 278 | - public function last_insert_id($table='', $primary_key='') |
|
| 278 | + public function last_insert_id($table = '', $primary_key = '') |
|
| 279 | 279 | { |
| 280 | 280 | /** |
| 281 | 281 | * Porque no funciona SELECT SCOPE_IDENTITY()? |