mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for #2416 fixes Invalid query when using boolean conditions in PostgreSQL
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4916 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1fa4e18487
commit
87cfb1766d
1 changed files with 17 additions and 8 deletions
|
@ -228,7 +228,7 @@ class DboPostgres extends DboSource {
|
|||
|
||||
break;
|
||||
case 'boolean':
|
||||
$data = $this->boolean((bool)$data);
|
||||
$data = $this->boolean((bool)$data, false);
|
||||
if ($data === true) {
|
||||
$data = '1';
|
||||
} elseif ($data === false) {
|
||||
|
@ -534,20 +534,29 @@ class DboPostgres extends DboSource {
|
|||
* Translates between PHP boolean values and PostgreSQL boolean values
|
||||
*
|
||||
* @param mixed $data Value to be translated
|
||||
* @param boolean $quote True to quote value, false otherwise
|
||||
* @return mixed Converted boolean value
|
||||
*/
|
||||
function boolean($data) {
|
||||
function boolean($data, $quote = true) {
|
||||
$result = null;
|
||||
|
||||
if ($data === true || $data === false) {
|
||||
return $data;
|
||||
$result = $data;
|
||||
} elseif (is_string($data) && !is_numeric($data)) {
|
||||
if (strpos($data, 't') !== false) {
|
||||
return true;
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return (bool)$data;
|
||||
$result = (bool)$data;
|
||||
}
|
||||
|
||||
if ($quote) {
|
||||
$result = "'" . $result . "'";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* Sets the database encoding
|
||||
|
@ -621,4 +630,4 @@ class DboPostgres extends DboSource {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue