2 Commits 14e6358d8c ... a247b2e3e0

Autore SHA1 Messaggio Data
  zjh a247b2e3e0 Merge commit '8ed49ed' 1 anno fa
  zjh 8ed49edb86 update 1 anno fa

+ 1 - 0
src/Autoloader/Psr4.php

@@ -329,6 +329,7 @@ class Psr4
         $class = $this->getClassName($class);
 
         if (class_exists($class, false)) {
+
             return call_user_func_array(array($this, 'instance'), $args);
         }
         if ($this->loadFileByClass($class)) {

+ 1 - 1
src/Driver/Base.php

@@ -1013,7 +1013,7 @@ class Base
             $extraParams = array_slice(func_get_args(), 2);
         }
         $where = array();
-        $operator = array('equal' => "%s`%s` = '%s'",'in' => "%s`%s` in (%s)", 'unequal' => "%s`%s` != '%s'", 'greater' => "%s`%s` > '%s'", 'greaterEqual' => "%s`%s` >= '%s'", 'less' => "%s`%s` < '%s'", 'lessEqual' => "%s`%s` <= '%s'", 'like' => "%s`%s` like '%%%s%%'");
+        $operator = array('equal' => "%s`%s` = '%s'",'in' => "%s`%s` in (%s)", 'unequal' => "%s`%s` != '%s'", 'greater' => "%s`%s` > '%s'", 'greaterEqual' => "%s`%s` >= '%s'", 'gte' => "%s`%s` >= '%s'", 'less' => "%s`%s` < '%s'", 'lessEqual' => "%s`%s` <= '%s'", 'lte' => "%s`%s` <= '%s'", 'like' => "%s`%s` like '%%%s%%'");
         $lastIsOperator = false;
         $lastIsValue = null;
         $i = 0;

+ 21 - 0
src/Driver/Entity/Base.php

@@ -335,6 +335,27 @@ class Base {
     }
 
     /**
+     * 清除变量内容
+     * @return $this
+     */
+    final public function clear() {
+        $class = get_called_class();
+        $method = new \ReflectionClass($class);
+        $properties = $method->getproperties();
+        $fields = [];
+        foreach($properties as $property) {
+            if($property->isPublic()) {
+                $name = $property->getName();
+                if(!isset($this->$name)) {
+                    continue;
+                }
+                $this->$name = null;
+            }
+        }
+        return $this;
+    }
+
+    /**
      * 获取默认值
      *
      * @return array

+ 9 - 3
src/Driver/Entity/Entity.php

@@ -140,10 +140,12 @@ class Entity {
  * @method \$this setLimitHooker(callable \$func)
  * @method \$this setCacheHooker(callable \$func)
  * @method \$this setQueryFieldsHooker(callable \$func)
+ * @method \$this clear()
+ * @method array properties()
  * @method bool exit()
  * @method \$this get()
  * @method Response info()
- * @method Response save()
+ * @method Response add()
  * @method Response remove()
  * @method Response update()
  * @method Response updateFields()
@@ -324,8 +326,10 @@ DOC;
      */
     public function primaryKey(){
 DOC;
+        $exclude = "\t\treturn array();";
         if($primaryKey) {
             $next[] = "\t\treturn array('". join("','", $this->convertToProperties($primaryKey)). "');";
+            $exclude = "\t\treturn array('". join("','", $this->convertToProperties($primaryKey)). "');";
         }else{
             $next[] = <<<DOC
         throw new \Exception('请设置主键');
@@ -336,12 +340,14 @@ DOC;
     }
 
     /**
-     * 保存数据的时候,验证唯一需要排除的值,此处仅支持,单个或联合排除,不支持单个排除
+     * 更新数据的时候,验证唯一需要排除的值,此处仅支持,单个或联合排除,不支持单个排除
      *
      * @return array
      */
     public function exclude(){
-        return array();
+DOC;
+        $next[] = $exclude;
+        $next[] = <<<DOC
     }
     /**
      * 添加时验证的字段,自行添加