|
@@ -12,7 +12,7 @@ class Base {
|
|
|
*
|
|
|
* @var array $properties
|
|
|
*/
|
|
|
- public static $properties;
|
|
|
+ protected $properties;
|
|
|
/**
|
|
|
* 配置信息
|
|
|
*
|
|
@@ -28,19 +28,19 @@ class Base {
|
|
|
* 主键
|
|
|
* @var mix $privateKeys null
|
|
|
*/
|
|
|
- public static $privateKeys = null;
|
|
|
+ protected $privateKeys = null;
|
|
|
/**
|
|
|
* 唯一字段
|
|
|
*
|
|
|
* @var array $uniqKeys
|
|
|
*/
|
|
|
- public static $uniqKeys = null;
|
|
|
+ protected $uniqKeys = null;
|
|
|
/**
|
|
|
* 设置排除项
|
|
|
*
|
|
|
* @var array $exclude
|
|
|
*/
|
|
|
- public static $exclude = [];
|
|
|
+ protected $exclude = [];
|
|
|
/**
|
|
|
* @var string 表别名
|
|
|
*/
|
|
@@ -82,10 +82,10 @@ class Base {
|
|
|
* @return void
|
|
|
*/
|
|
|
final public function cleanVars() {
|
|
|
- self::$properties = [];
|
|
|
- self::$uniqKeys = null;
|
|
|
- self::$privateKeys = null;
|
|
|
- self::$exclude = [];
|
|
|
+ $this->properties = [];
|
|
|
+ $this->uniqKeys = null;
|
|
|
+ $this->privateKeys = null;
|
|
|
+ $this->exclude = [];
|
|
|
}
|
|
|
/**
|
|
|
* 默认值,仅在新增数据的时候支持,更新不支持
|
|
@@ -580,7 +580,7 @@ class Base {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function setUniqKeys($uniqKeys) {
|
|
|
- self::$uniqKeys = $uniqKeys;
|
|
|
+ $this->uniqKeys = $uniqKeys;
|
|
|
}
|
|
|
/**
|
|
|
* unique (unique 如果是 array 则表示 联合唯一,如果是string则是任意唯一,多个单独唯一使用字符串以逗号隔开, 主键除外)
|
|
@@ -589,8 +589,8 @@ class Base {
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
public function uniqueKey(){
|
|
|
- if(self::$uniqKeys !== null) {
|
|
|
- return self::$uniqKeys;
|
|
|
+ if($this->uniqKeys !== null) {
|
|
|
+ return $this->uniqKeys;
|
|
|
}
|
|
|
throw new \Exception('请设置唯一值');
|
|
|
}
|
|
@@ -602,7 +602,7 @@ class Base {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function setPrivateKey($privateKeys){
|
|
|
- self::$privateKeys = $privateKeys;
|
|
|
+ $this->privateKeys = $privateKeys;
|
|
|
}
|
|
|
/**
|
|
|
* 主键
|
|
@@ -611,8 +611,8 @@ class Base {
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
public function primaryKey(){
|
|
|
- if(self::$privateKeys !== null) {
|
|
|
- return self::$privateKeys;
|
|
|
+ if($this->privateKeys !== null) {
|
|
|
+ return $this->privateKeys;
|
|
|
}
|
|
|
throw new \Exception('请设置主键');
|
|
|
}
|
|
@@ -626,7 +626,7 @@ class Base {
|
|
|
if(!is_array($exclude)) {
|
|
|
return;
|
|
|
}
|
|
|
- self::$exclude = $exclude;
|
|
|
+ $this->exclude = $exclude;
|
|
|
}
|
|
|
/**
|
|
|
* 保存数据的时候,验证唯一需要排除的值,此处仅支持,单个或联合排除,不支持单个异或排除
|
|
@@ -634,8 +634,8 @@ class Base {
|
|
|
* @return array
|
|
|
*/
|
|
|
public function exclude(){
|
|
|
- if(self::$exclude !== null) {
|
|
|
- return self::$exclude;
|
|
|
+ if($this->exclude !== null) {
|
|
|
+ return $this->exclude;
|
|
|
}
|
|
|
return array();
|
|
|
}
|
|
@@ -776,8 +776,8 @@ class Base {
|
|
|
public function hasProperty($key) {
|
|
|
$class = get_called_class();
|
|
|
$key = $this->entity()->convertToProperty($key);
|
|
|
- if(isset(self::$properties[$class])) {
|
|
|
- return isset(self::$properties[$class][$key]);
|
|
|
+ if(isset($this->properties[$class])) {
|
|
|
+ return isset($this->properties[$class][$key]);
|
|
|
}
|
|
|
$method = new \ReflectionClass($class);
|
|
|
$properties = $method->getproperties();
|
|
@@ -788,7 +788,7 @@ class Base {
|
|
|
$fields[$name] = '';
|
|
|
}
|
|
|
}
|
|
|
- self::$properties[$class] = $fields;
|
|
|
+ $this->properties[$class] = $fields;
|
|
|
return isset($fields[$key]);
|
|
|
}
|
|
|
|