From 87ab8ba4f3d01d9f76ba0f53033fa83b5c88a52c Mon Sep 17 00:00:00 2001 From: Catfan Date: Sat, 24 Mar 2018 01:51:09 +0800 Subject: [PATCH 1/4] [fix] Medoo::raw for aggregate functions #726 --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 0213f1ba..b301b298 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -1003,7 +1003,7 @@ protected function selectContext($table, &$map, $join, &$columns = null, $where } else { - if (empty($columns)) + if (empty($columns) || $this->isRaw($columns)) { $columns = '*'; $where = $join; From d28ae104aa962011533740d2eb1da3e51c14a2ac Mon Sep 17 00:00:00 2001 From: Catfan Date: Sat, 24 Mar 2018 03:14:47 +0800 Subject: [PATCH 2/4] [fix] Casting Null to Int gives 0 #721 --- src/Medoo.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Medoo.php b/src/Medoo.php index b301b298..05c817f9 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -1082,6 +1082,8 @@ protected function dataMap($data, $columns, $column_map, &$stack) $column_key = $map[ 0 ]; + $result = $data[ $column_key ]; + if (isset($map[ 1 ])) { if ($isRaw && in_array($map[ 1 ], ['Object', 'JSON'])) @@ -1089,36 +1091,42 @@ protected function dataMap($data, $columns, $column_map, &$stack) continue; } + if (is_null($result)) + { + $stack[ $column_key ] = null; + continue; + } + switch ($map[ 1 ]) { case 'Number': - $stack[ $column_key ] = (double) $data[ $column_key ]; + $stack[ $column_key ] = (double) $result; break; case 'Int': - $stack[ $column_key ] = (int) $data[ $column_key ]; + $stack[ $column_key ] = (int) $result; break; case 'Bool': - $stack[ $column_key ] = (bool) $data[ $column_key ]; + $stack[ $column_key ] = (bool) $result; break; case 'Object': - $stack[ $column_key ] = unserialize($data[ $column_key ]); + $stack[ $column_key ] = unserialize($result); break; case 'JSON': - $stack[ $column_key ] = json_decode($data[ $column_key ], true); + $stack[ $column_key ] = json_decode($result, true); break; case 'String': - $stack[ $column_key ] = $data[ $column_key ]; + $stack[ $column_key ] = $result; break; } } else { - $stack[ $column_key ] = $data[ $column_key ]; + $stack[ $column_key ] = $result; } } else From ddb307f7acd569b49d22696bd3a4194851164f3a Mon Sep 17 00:00:00 2001 From: Catfan Date: Sat, 24 Mar 2018 03:47:52 +0800 Subject: [PATCH 3/4] [fix] Fix connecting two column with != operator #727 --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 05c817f9..30b40191 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -541,7 +541,7 @@ protected function dataImplode($data, &$map, $conjunctor) if ( is_int($key) && - preg_match('/([a-zA-Z0-9_\.]+)\[(?\>\=?|\<\=?|\!|\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match) + preg_match('/([a-zA-Z0-9_\.]+)\[(?\>\=?|\<\=?|\!?\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match) ) { $stack[] = $this->columnQuote($match[ 1 ]) . ' ' . $match[ 'operator' ] . ' ' . $this->columnQuote($match[ 3 ]); From 4b29403f85b4aebe9fbe0538e39e00bb88975c5e Mon Sep 17 00:00:00 2001 From: Catfan Date: Tue, 27 Mar 2018 01:53:12 +0800 Subject: [PATCH 4/4] [release] Medoo 1.5.6 --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 30b40191..1640ca69 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -2,7 +2,7 @@ /*! * Medoo database framework * https://medoo.in - * Version 1.5.5 + * Version 1.5.6 * * Copyright 2018, Angel Lai * Released under the MIT license