添加api接口的支持

This commit is contained in:
thinkphp
2015-05-12 15:34:04 +08:00
parent d886644b58
commit 36a84e75de
20 changed files with 247 additions and 196 deletions

View File

@@ -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;
}
}