修正traits

This commit is contained in:
thinkphp
2016-01-30 23:20:30 +08:00
parent 601a6dc945
commit 5fda023980
3 changed files with 13 additions and 21 deletions

View File

@@ -14,9 +14,6 @@ namespace traits\model;
trait Adv
{
protected $optimLock = 'lock_version';
//protected $serializeField = [];
//protected $readonlyField = [];
//protected $partition = [];
/**
* 利用__call方法重载 实现一些特殊的Model方法 (魔术方法)

View File

@@ -15,9 +15,6 @@ use think\Lang;
trait Auto
{
//protected $validate = []; // 自动验证定义
//protected $auto = []; // 自动完成定义
/**
* 创建数据对象 但不保存到数据库
* @access public
@@ -195,7 +192,7 @@ trait Auto
switch (trim($auto[3])) {
case 'function': // 使用函数进行填充 字段的值作为参数
case 'callback': // 使用回调方法
$args = isset($auto[4]) ? (array)$auto[4] : [];
$args = isset($auto[4]) ? (array) $auto[4] : [];
if (is_string($auto[0]) && strpos($auto[0], ',')) {
$auto[0] = explode(',', $auto[0]);
}
@@ -211,7 +208,7 @@ trait Auto
if ('function' == $auto[3]) {
$data[$auto[0]] = call_user_func_array($auto[1], $args);
} else {
$data[$auto[0]] = call_user_func_array([& $this, $auto[1]], $args);
$data[$auto[0]] = call_user_func_array([ & $this, $auto[1]], $args);
}
break;
case 'field': // 用其它字段的值进行填充
@@ -358,7 +355,7 @@ trait Auto
switch (strtolower(trim($val[4]))) {
case 'function': // 使用函数进行验证
case 'callback': // 调用方法进行验证
$args = isset($val[6]) ? (array)$val[6] : [];
$args = isset($val[6]) ? (array) $val[6] : [];
if (is_string($val[0]) && strpos($val[0], ',')) {
$val[0] = explode(',', $val[0]);
}
@@ -371,7 +368,7 @@ trait Auto
} else {
array_unshift($args, isset($data[$val[0]]) ? $data[$val[0]] : null);
}
return call_user_func_array('function' == $val[4] ? $val[1] : [& $this, $val[1]], $args);
return call_user_func_array('function' == $val[4] ? $val[1] : [ & $this, $val[1]], $args);
case 'confirm': // 验证两个字段是否相同
return $data[$val[0]] == $data[$val[1]];
case 'unique': // 验证某个值是否唯一

View File

@@ -14,8 +14,6 @@ namespace traits\model;
trait View
{
protected $viewFields = [];
/**
* 自动检测数据表信息
* @access protected