rabin 7 年之前
父节点
当前提交
c63cf7e3ad
共有 1 个文件被更改,包括 12 次插入4 次删除
  1. 12 4
      src/Database.php

+ 12 - 4
src/Database.php

@@ -1882,7 +1882,7 @@ class Database
      */
     public function update_html($param, $key, $index, $data, &$result)
     {
-        if (isset($param['name']) && $param['update'] != 'hidden' && is_string($param['update'])) {
+        if (isset($param['name']) && $param['update'] != 'hidden' && isset($param['update'])) {
             $result[$key] .= Html::pageLeft($param);
         }
 
@@ -2027,9 +2027,9 @@ class Database
             Dever::setInput('where_id', $this->id);
             //Dever::setInput('update_where_id', $this->id);
 
-            $info = $this->load();
-
+            $info = $this->load('one', $this->id);
             if ($info) {
+
                 $method = 'update';
 
                 $col = Dever::input('col');
@@ -2053,6 +2053,9 @@ class Database
                 }
 
                 $prefix = 'set';
+            } else {
+                $method = 'insert';
+                $prefix = 'add';
             }
         }
         if (!$method) {
@@ -2079,6 +2082,9 @@ class Database
                     }
                 }
                 if (strpos($k, '_c_') !== false) {
+                    if ($v == 'null') {
+                        $v = '';
+                    }
                     $temp = explode('_c_', $k);
                     $k = str_replace('update_', $prefix . '_', $temp[0]);
                     if (!isset($c[$k])) {
@@ -2161,7 +2167,9 @@ class Database
                 }
             }
 
-            //print_r($update);die;
+            if ($this->id && !$info) {
+                $update[0]['add_id'] = $this->id;
+            }
 
             foreach ($update as $k => $v) {
                 $method = 'insert';