Skip to content

Commit

Permalink
fixed updatemany deletemany
Browse files Browse the repository at this point in the history
  • Loading branch information
lhs168 committed Mar 30, 2018
1 parent 9eac5de commit 230904a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Fasim/Core/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,25 @@ public static function db($m = null) {

public static function updateMany($where, $updates) {
$m = new static();
$where = static::_convertValues($m, $where);
$updates = static::_convertValues($m, $updates);
static::db()->update($m->getTableName(), $where, $updates);
}

public static function deleteMany($where) {
$m = new static();
static::db()->delete($m->getTableName(), $where);
static::db()->delete($m->getTableName(), static::_convertValues($m, $where));
}

private static function _convertValues($m, $where) {
if (is_array($where)) {
//值转换
foreach ((array)$where as $k => $v) {
$m->$k = $v;
$where[$k] = $m->getOriginalValue($k);
}
}
return $where;
}


Expand Down

0 comments on commit 230904a

Please sign in to comment.