mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
This fixes an issue where attempting to use "!=" in a condition with an array with only a single element generates invalid SQL.
Example: $condition['Model.id !='] = array(1, 2); //Generates Model.id NOT IN (1, 2) as expected $condition['Model.id !='] = array(1); //Generates Model.id != = (1) which is invalid SQL Patch will cause the above to generate Model.id != (1); This an implimentation of @markstory's suggestion on PR 1232
This commit is contained in:
parent
fb86859585
commit
9e6120c86a
1 changed files with 1 additions and 1 deletions
|
@ -2494,7 +2494,7 @@ class DboSource extends DataSource {
|
||||||
$keys = array_keys($value);
|
$keys = array_keys($value);
|
||||||
if ($keys === array_values($keys)) {
|
if ($keys === array_values($keys)) {
|
||||||
$count = count($value);
|
$count = count($value);
|
||||||
if ($count === 1 && !preg_match("/\s+NOT$/", $key)) {
|
if ($count === 1 && !preg_match('/\s+(?:NOT|\!=)$/', $key)) {
|
||||||
$data = $this->_quoteFields($key) . ' = (';
|
$data = $this->_quoteFields($key) . ' = (';
|
||||||
if ($quoteValues) {
|
if ($quoteValues) {
|
||||||
if (is_object($model)) {
|
if (is_object($model)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue