From 6821eb6f9b2b587ada3bfc5df58d022f6794476e Mon Sep 17 00:00:00 2001 From: Catfan Date: Wed, 20 Dec 2017 03:38:43 +0800 Subject: [PATCH 1/4] [fix] Fix #690 incorrect AND and OR key detection on where clause --- src/Medoo.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Medoo.php b/src/Medoo.php index 8a5322e7..7de66311 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -521,19 +521,17 @@ protected function dataImplode($data, &$map, $conjunctor) { $type = gettype($value); - if ($type === 'array') + if ( + $type === 'array' && + ) { - $relationship = strpos($key, 'AND', 0) !== false ? 'AND' : - (strpos($key, 'OR', 0) !== false ? 'OR' : false); + $relationship = $relation_match[ 1 ]; - if ($relationship) - { - $stack[] = !empty(array_diff_key($value, array_keys(array_keys($value)))) ? - '(' . $this->dataImplode($value, $map, ' ' . $relationship) . ')' : - '(' . $this->innerConjunct($value, $map, ' ' . $relationship, $conjunctor) . ')'; + $stack[] = !empty(array_diff_key($value, array_keys(array_keys($value)))) ? + '(' . $this->dataImplode($value, $map, ' ' . $relationship) . ')' : + '(' . $this->innerConjunct($value, $map, ' ' . $relationship, $conjunctor) . ')'; - continue; - } + continue; } $map_key = $this->mapKey(); From 797b1e3cf037454854b4cc601ed0173fc4a77b0a Mon Sep 17 00:00:00 2001 From: Catfan Date: Wed, 20 Dec 2017 03:41:39 +0800 Subject: [PATCH 2/4] [fix] Fix 6821eb commit --- src/Medoo.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Medoo.php b/src/Medoo.php index 7de66311..e9bc5d6e 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -523,6 +523,7 @@ protected function dataImplode($data, &$map, $conjunctor) if ( $type === 'array' && + preg_match("/^(AND|OR)(\s+#.*)?$/", $key, $relation_match) ) { $relationship = $relation_match[ 1 ]; From a40ab7f8729bbc7f6c8341744693882120cc0e3c Mon Sep 17 00:00:00 2001 From: Catfan Date: Tue, 26 Dec 2017 00:59:35 +0800 Subject: [PATCH 3/4] [fix] Fix and improve dimension array comparison with where clause --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index e9bc5d6e..776d211a 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -528,7 +528,7 @@ protected function dataImplode($data, &$map, $conjunctor) { $relationship = $relation_match[ 1 ]; - $stack[] = !empty(array_diff_key($value, array_keys(array_keys($value)))) ? + $stack[] = $value !== array_keys(array_keys($value)) ? '(' . $this->dataImplode($value, $map, ' ' . $relationship) . ')' : '(' . $this->innerConjunct($value, $map, ' ' . $relationship, $conjunctor) . ')'; From 59c2f1ab801dbf3582bd1d725fa727df326bcc25 Mon Sep 17 00:00:00 2001 From: Catfan Date: Tue, 26 Dec 2017 01:02:07 +0800 Subject: [PATCH 4/4] [release] Medoo 1.5.3 --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 776d211a..61a23f67 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -2,7 +2,7 @@ /*! * Medoo database framework * https://medoo.in - * Version 1.5.2 + * Version 1.5.3 * * Copyright 2017, Angel Lai * Released under the MIT license