From 458560a2e74be97171672c681b9c93ed97c6ff7c Mon Sep 17 00:00:00 2001 From: Ulises Jeremias Cornejo Fandos Date: Fri, 17 Nov 2017 15:57:19 -0300 Subject: [PATCH] Update Model.php --- Mbh/Model.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Mbh/Model.php b/Mbh/Model.php index 8574532..bfbe404 100644 --- a/Mbh/Model.php +++ b/Mbh/Model.php @@ -195,6 +195,18 @@ public static function update($e, $where = "1=1", $limit = "") return static::$db->update(static::$table['name'], $e, $where, $limit); } + + public static function updateWith($data) + { + $column = array_search(static::$table['idColumn'], static::$columnData); + $class = get_called_class(); + foreach ($data as $key => $value) { + $new_data = new $class($value); + if (!$new_data->refresh()->getStateAttr($column)) { + $new_data->save(); + } + } + } /** * Selects and lists in an associative / numeric array the results of a search in the database @@ -331,18 +343,6 @@ public function remove() return $this; } - public static function updateWith($data) - { - $column = array_search(static::$table['idColumn'], static::$columnData); - $class = get_called_class(); - foreach ($data as $key => $value) { - $new_data = new $class($value); - if (!$new_data->refresh()->getStateAttr($column)) { - $new_data->save(); - } - } - return $this; - } public function __toString() { return json_encode($this->state);