mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-05 22:52:49 +08:00
添加api接口的支持
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace traits\think\model;
|
||||
|
||||
use think\Loader;
|
||||
trait Extend {
|
||||
|
||||
protected $partition = [];
|
||||
@@ -29,18 +29,18 @@ trait Extend {
|
||||
return $this->getField(strtoupper($method).'('.$field.') AS tp_'.$method);
|
||||
}elseif(strtolower(substr($method,0,5))=='getby') {
|
||||
// 根据某个字段获取记录
|
||||
$field = parse_name(substr($method,5));
|
||||
$field = Loader::parseName(substr($method,5));
|
||||
$where[$field] = $args[0];
|
||||
return $this->where($where)->find();
|
||||
}elseif(strtolower(substr($method,0,10))=='getfieldby') {
|
||||
// 根据某个字段获取记录的某个值
|
||||
$name = parse_name(substr($method,10));
|
||||
$name = Loader::parseName(substr($method,10));
|
||||
$where[$name] =$args[0];
|
||||
return $this->where($where)->getField($args[1]);
|
||||
}elseif(isset($this->scope[$method])){// 命名范围的单独调用支持
|
||||
return $this->scope($method,$args[0]);
|
||||
}else{
|
||||
E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
|
||||
throw new \think\Exception(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user