Changeset 3743:07ef48e3d0e5
- Timestamp:
- 03/30/18 00:15:46 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.selectstatement.php
r3742 r3743 149 149 } 150 150 if (is_array($c)) { 151 $c = array_map(trim(ltrim($c, ',')), $c); // Cope with legacy code 151 $filter = function($v) { 152 return trim(ltrim($v, ',')); 153 }; 154 $c = array_map($filter, $c); // Cope with legacy code 152 155 $this->from = array_merge($this->from, $c); 153 156 } else { … … 360 363 361 364 /** 362 * Escape a n identifier363 * 364 * @param string $ identifier The identifier365 * Escape a value 366 * 367 * @param string $value The value 365 368 * 366 369 * @return string 367 370 */ 368 public function escape($ identifier)369 { 370 return $this->con->escape($ identifier);371 public function escape($value) 372 { 373 return $this->con->escape($value); 371 374 } 372 375 … … 394 397 { 395 398 return $this->con->dateFormat($field, $pattern); 399 } 400 401 /** 402 * Return an SQL formatted REGEXP clause 403 * 404 * @param string $value The value 405 * 406 * @return string 407 */ 408 public function regexp($value) 409 { 410 if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') { 411 $clause = "REGEXP '^" . $this->escape(preg_quote($value)) . "[0-9]+$'"; 412 } elseif ($this->con->driver() == 'pgsql') { 413 $clause = "~ '^" . $this->escape(preg_quote($value)) . "[0-9]+$'"; 414 } else { 415 $clause = "LIKE '" . 416 $sql->escape(preg_replace(array('%', '_', '!'), array('!%', '!_', '!!'), $value)) . 417 "%' ESCAPE '!'"; 418 } 419 return $clause; 420 } 421 422 /** 423 * Quote and escape a value if necessary (type string) 424 * 425 * @param mixed $value The value 426 * @param boolean $escape The escape 427 * 428 * @return string 429 */ 430 public function quote($value, $escape = true) 431 { 432 return 433 (is_string($value) ? "'" : '') . 434 ($escape ? $this->con->escape($value) : $value) . 435 (is_string($value) ? "'" : ''); 396 436 } 397 437 … … 470 510 } 471 511 472 return $query;512 return trim($query); 473 513 } 474 514 … … 496 536 '\( ' => '(' // (<space> -> ( 497 537 ); 498 foreach ($patterns as $ from => $to) {499 $s = preg_replace('!' . $ from . '!', $to, $s);538 foreach ($patterns as $pattern => $replace) { 539 $s = preg_replace('!' . $pattern . '!', $replace, $s); 500 540 } 501 541 return $s; 502 542 }; 503 return ($filter($local) !== $filter($external));543 return ($filter($local) === $filter($external)); 504 544 } 505 545 }
Note: See TracChangeset
for help on using the changeset viewer.