From a4512ec557a973661c2e604153ecafe245cfb36d Mon Sep 17 00:00:00 2001 From: Catfan Date: Mon, 22 May 2017 01:02:37 +0800 Subject: [PATCH 1/4] [fix] Fix displaying statement error #568 --- src/Medoo.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 13425e71..61fe3dd5 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -20,6 +20,8 @@ class Medoo protected $prefix; + protected $statement; + protected $option = []; protected $logs = []; @@ -303,6 +305,8 @@ public function exec($query, $map = []) $statement->execute(); + $this->statement = $statement; + return $statement; } @@ -1441,7 +1445,7 @@ public function debug() public function error() { - return $this->pdo->errorInfo(); + return $this->statement->errorInfo(); } public function last() From 6c3eb28634f8cb78b3dba46e9bab72320bb08c15 Mon Sep 17 00:00:00 2001 From: Catfan Date: Mon, 22 May 2017 02:12:09 +0800 Subject: [PATCH 2/4] [fix] Fix SQL function support #574 --- src/Medoo.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Medoo.php b/src/Medoo.php index 61fe3dd5..882a22c6 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -1095,6 +1095,12 @@ public function insert($table, $datas) foreach ($columns as $key) { + if (strpos($key, '#') === 0) + { + $values[] = $this->fnQuote($key, $data[ $key ]); + continue; + } + $map_key =$this->mapKey(); $values[] = $map_key; @@ -1164,6 +1170,13 @@ public function update($table, $data, $where = null) foreach ($data as $key => $value) { + if (strpos($key, '#') === 0) + { + $column = $this->columnQuote(preg_replace("/(^#|\s*\[JSON\]$)/i", '', $key)); + $fields[] = $column . ' = ' . $value; + continue; + } + $map_key = $this->mapKey(); preg_match('/(?[a-zA-Z0-9_]+)(\[(?\+|\-|\*|\/)\])?/i', $key, $match); From 7ebc922cd21a293cb61e15ddf6a6058dc27860a8 Mon Sep 17 00:00:00 2001 From: Catfan Date: Mon, 22 May 2017 12:13:10 +0800 Subject: [PATCH 3/4] [update] Improve update code --- src/Medoo.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Medoo.php b/src/Medoo.php index 882a22c6..8524f12c 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -1170,9 +1170,10 @@ public function update($table, $data, $where = null) foreach ($data as $key => $value) { + $column = $this->columnQuote(preg_replace("/(^#|\s*\[(JSON|\+|\-|\*|\/)\]$)/i", '', $key)); + if (strpos($key, '#') === 0) { - $column = $this->columnQuote(preg_replace("/(^#|\s*\[JSON\]$)/i", '', $key)); $fields[] = $column . ' = ' . $value; continue; } @@ -1185,12 +1186,11 @@ public function update($table, $data, $where = null) { if (is_numeric($value)) { - $fields[] = $this->columnQuote($match[ 'column' ]) . ' = ' . $this->columnQuote($match[ 'column' ]) . ' ' . $match[ 'operator' ] . ' ' . $value; + $fields[] = $column . ' = ' . $column . ' ' . $match[ 'operator' ] . ' ' . $value; } } else { - $column = $this->columnQuote(preg_replace("/(^#|\s*\[JSON\]$)/i", '', $key)); $fields[] = $column . ' = ' . $map_key; switch (gettype($value)) From 865854b25e1b456c00f72d4dd2debc89cbb352ff Mon Sep 17 00:00:00 2001 From: Catfan Date: Mon, 22 May 2017 12:39:14 +0800 Subject: [PATCH 4/4] [release] Medoo 1.4.3 --- src/Medoo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Medoo.php b/src/Medoo.php index 8524f12c..8e5ee340 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -2,7 +2,7 @@ /*! * Medoo database framework * https://medoo.in - * Version 1.4.2 + * Version 1.4.3 * * Copyright 2017, Angel Lai * Released under the MIT license