From bb834494bd05015a0b4dd6d95949d43523c6b2d9 Mon Sep 17 00:00:00 2001 From: Gregorio Chiko Putra Date: Wed, 6 Sep 2017 14:48:47 +0700 Subject: [PATCH] Cannot update with same value --- Core/Model.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Core/Model.php b/Core/Model.php index 3b6f15b..6140362 100644 --- a/Core/Model.php +++ b/Core/Model.php @@ -144,6 +144,19 @@ abstract class Model try { $db = static::connectDB(); + $result = $this->showAll(); + + foreach ($result as $post) { + foreach ($post as $key => $val) { + if (isset($args[$key])) { + if ($args[$key] == $post[$key]) { + return false; + } + } + } + } + + $sql = "UPDATE {$table} SET {$fields} WHERE id = ?"; $query = $db->prepare($sql);