Skip to content

Commit 458560a

Browse files
Update Model.php
1 parent d9a0c64 commit 458560a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Mbh/Model.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ public static function update($e, $where = "1=1", $limit = "")
195195

196196
return static::$db->update(static::$table['name'], $e, $where, $limit);
197197
}
198+
199+
public static function updateWith($data)
200+
{
201+
$column = array_search(static::$table['idColumn'], static::$columnData);
202+
$class = get_called_class();
203+
foreach ($data as $key => $value) {
204+
$new_data = new $class($value);
205+
if (!$new_data->refresh()->getStateAttr($column)) {
206+
$new_data->save();
207+
}
208+
}
209+
}
198210

199211
/**
200212
* Selects and lists in an associative / numeric array the results of a search in the database
@@ -331,18 +343,6 @@ public function remove()
331343
return $this;
332344
}
333345

334-
public static function updateWith($data)
335-
{
336-
$column = array_search(static::$table['idColumn'], static::$columnData);
337-
$class = get_called_class();
338-
foreach ($data as $key => $value) {
339-
$new_data = new $class($value);
340-
if (!$new_data->refresh()->getStateAttr($column)) {
341-
$new_data->save();
342-
}
343-
}
344-
return $this;
345-
}
346346
public function __toString()
347347
{
348348
return json_encode($this->state);

0 commit comments

Comments
 (0)