mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-02 21:52:34 +08:00
修正Driver当写入空数据的问题
This commit is contained in:
@@ -286,12 +286,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
if (false === $this->trigger('before_update', $this)) {
|
||||
return false;
|
||||
}
|
||||
// 更新的时候检测字段更改
|
||||
if (!empty($this->change)) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $this->change) && !$this->isPk($key) && !isset($this->relation[$key])) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
// 去除没有更新的字段
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $this->change) && !$this->isPk($key) && !isset($this->relation[$key])) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1350,6 +1350,9 @@ abstract class Driver
|
||||
*/
|
||||
protected function parseData($data, $bind)
|
||||
{
|
||||
if (empty($data)) {
|
||||
return [];
|
||||
}
|
||||
$fields = array_keys($bind);
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $fields, true)) {
|
||||
@@ -1761,7 +1764,10 @@ abstract class Driver
|
||||
$options = $this->_parseOptions();
|
||||
$bind = $this->getTableInfo($options['table'], 'bind');
|
||||
|
||||
$data = $this->parseData($data, $bind);
|
||||
$data = $this->parseData($data, $bind);
|
||||
if (empty($data)) {
|
||||
return 0;
|
||||
}
|
||||
$fields = array_keys($data);
|
||||
$values = array_values($data);
|
||||
// 兼容数字传入方式
|
||||
@@ -1854,7 +1860,9 @@ abstract class Driver
|
||||
$bind = $this->getTableInfo($options['table'], 'bind');
|
||||
$table = $this->parseTable($options['table']);
|
||||
$data = $this->parseData($data, $bind);
|
||||
|
||||
if (empty($data)) {
|
||||
return 0;
|
||||
}
|
||||
foreach ($data as $key => $val) {
|
||||
$set[] = $key . '=' . $val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user