mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
save方法改进复合主键的支持
This commit is contained in:
@@ -1070,12 +1070,17 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
if (is_string($pk) && isset($data[$pk])) {
|
||||
if (!isset($where[$pk])) {
|
||||
unset($where);
|
||||
$where[$pk] = $data[$pk];
|
||||
$array = [];
|
||||
|
||||
foreach ((array) $pk as $key) {
|
||||
if (isset($data[$key])) {
|
||||
$array[] = [$key, '=', $data[$key]];
|
||||
unset($data[$key]);
|
||||
}
|
||||
unset($data[$pk]);
|
||||
}
|
||||
|
||||
if (!empty($array)) {
|
||||
$where = $array;
|
||||
}
|
||||
|
||||
// 检测字段
|
||||
|
||||
Reference in New Issue
Block a user