Browse Source

update entity and fixed some bugs

朱金辉 1 year ago
parent
commit
d79c96f5ee
2 changed files with 8 additions and 5 deletions
  1. 7 4
      src/Driver/Entity/Base.php
  2. 1 1
      src/Driver/Entity/Entity.php

+ 7 - 4
src/Driver/Entity/Base.php

@@ -552,10 +552,6 @@ class Base {
                 );
             }
         }
-        /*$whereHooker = $this->getWhereHooker();
-        if(!empty($whereHooker)) {
-            $primaryKey = $whereHooker;
-        }*/
         $where = [];
         $whereHooker = $this->getWhereHooker();
         foreach ($whereHooker as $key => $val) {
@@ -689,6 +685,13 @@ class Base {
         }
         $whereHooker = $this->getWhereHooker();
         if(!empty($whereHooker)) {
+            foreach ($whereHooker as $key => $where) {
+                //去掉where条件里边的sets的值
+                $keys = $this->explode(":", $key);
+                if(isset($diff[$keys[0]])) {
+                    unset($whereHooker[$key]);
+                }
+            }
             $primary = $whereHooker;
         }
         $affectedRows = $this->db()->set($sets)->where($primary)->update($this->getTable());

+ 1 - 1
src/Driver/Entity/Entity.php

@@ -346,7 +346,7 @@ DOC;
      * 添加时验证的字段,自行添加
      */
     public function validFieldsForAdd(){
-    DOC;
+DOC;
         if(count($validForSave) > 0) {
             $next[] = "\t\$fields = array('". join("', '", $validForSave)."');";
         }else{