zjh před 5 měsíci
rodič
revize
a4e6adaa19
2 změnil soubory, kde provedl 10 přidání a 5 odebrání
  1. 9 4
      src/Driver/Entity/Base.php
  2. 1 1
      src/Driver/Entity/Entity.php

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

@@ -76,7 +76,13 @@ class Base {
         $this->cleanVars();
     }
 
+    /**
+     * 初始化的时候清除所有静态变量的值
+     *
+     * @return void
+     */
     final public function cleanVars() {
+        self::$properties = [];
         self::$uniqKeys = null;
         self::$privateKeys = null;
         self::$exclude = [];
@@ -758,7 +764,6 @@ class Base {
         $query->fields(' COUNT(1) as count');
         return $query->selectOne($this->prepareTable());
     }
-
     /**
      * 检查是否有对应的属性
      *
@@ -766,6 +771,7 @@ class Base {
      * @return bool
      * @throws \ReflectionException
      */
+    private $__property = [];
     public function hasProperty($key) {
         $class = get_called_class();
         $key = $this->entity()->convertToProperty($key);
@@ -776,8 +782,8 @@ class Base {
         $properties = $method->getproperties();
         $fields = array();
         foreach($properties as $property) {
-            if($property->isPublic()) {
-                $name = $property->getName();
+            $name = $property->getName();
+            if($property->isPublic() && preg_match('/^[A-Z\_].*?/', $name)) {
                 $fields[$name] = '';
             }
         }
@@ -997,7 +1003,6 @@ class Base {
         //如果设置了 unique 就先验证唯一性
         list($uniqueWhere, $uniqueOr, $exclude, $primary) = $this->condition();
         unset($exclude);
-
         //如果 $where $or 为空,看看主键是否有设置值,有设置值说明验证主键就可以,反之设置了主键,主键值设置了,只验证主键就可以了
         if(count($primary) > 0) {
             $exist = $this->db()->limit(1)->where($primary)->selectRow($this->prepareTable());

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

@@ -177,7 +177,7 @@ DOC;
 DOC;
             ;
             $classAndProperty[] = "\tpublic function __construct(){";
-            $classAndProperty[] = "\n";
+            $classAndProperty[] = "\t\tparent::__construct();";
             $classAndProperty[] = "\t}";
 
             $classAndProperty[] = <<<DOC