mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing quoting of boolean values in DboPostgres (Ticket #2594)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5416 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
79147c297f
commit
629c0a9d63
2 changed files with 101 additions and 108 deletions
|
@ -241,14 +241,12 @@ class DboPostgres extends DboSource {
|
|||
|
||||
break;
|
||||
case 'boolean':
|
||||
$data = $this->boolean((bool)$data, false);
|
||||
if ($data === true) {
|
||||
$data = '1';
|
||||
} elseif ($data === false) {
|
||||
$data = '0';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($data === true) {
|
||||
return 'TRUE';
|
||||
} elseif ($data === false) {
|
||||
return 'FALSE';
|
||||
}
|
||||
$data = pg_escape_string($data);
|
||||
break;
|
||||
}
|
||||
|
@ -558,7 +556,7 @@ class DboPostgres extends DboSource {
|
|||
if ($data === true || $data === false) {
|
||||
$result = $data;
|
||||
} elseif (is_string($data) && !is_numeric($data)) {
|
||||
if (strpos($data, 't') !== false) {
|
||||
if (strpos(low($data), 't') !== false) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
|
@ -566,11 +564,6 @@ class DboPostgres extends DboSource {
|
|||
} else {
|
||||
$result = (bool)$data;
|
||||
}
|
||||
|
||||
if ($quote) {
|
||||
$result = "'" . $result . "'";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -216,7 +216,7 @@ class DboSource extends DataSource {
|
|||
$c = 0;
|
||||
$query = array();
|
||||
foreach ($field as $f) {
|
||||
if (!is_array($params[$c]) && !empty($params[$c])) {
|
||||
if (!is_array($params[$c]) && !empty($params[$c]) && $params[$c] !== true && $params[$c] !== false) {
|
||||
$query[$args[2]->name . '.' . $f] = '= ' . $params[$c];
|
||||
} else {
|
||||
$query[$args[2]->name . '.' . $f] = $params[$c];
|
||||
|
@ -1550,7 +1550,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
} elseif ($value === null || (is_array($value) && empty($value))) {
|
||||
$data = $this->name($key) . ' IS NULL';
|
||||
} elseif ($value === false || $value === true) {
|
||||
$data = $this->name($key) . " = " . $this->boolean($value);
|
||||
$data = $this->name($key) . " = " . $this->value($value, 'boolean');
|
||||
} elseif ($value === '') {
|
||||
$data = $this->name($key) . " = ''";
|
||||
} elseif (preg_match('/^([a-z]+\\([a-z0-9]*\\)\\x20+|(?:' . join('\\x20)|(?:', $this->__sqlOps) . '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)?(.*)/i', $value, $match)) {
|
||||
|
|
Loading…
Reference in a new issue