更新内核,API接口开发的一些尝试,后期会增加API接口开发这块

This commit is contained in:
2017-05-22 20:48:10 +08:00
parent a4d58f9f09
commit 426195eb90
47 changed files with 1339 additions and 513 deletions

View File

@@ -33,8 +33,6 @@ abstract class Relation
protected $foreignKey;
// 关联表主键
protected $localKey;
// 关联查询参数
protected $option;
// 基础查询
protected $baseQuery;
@@ -79,15 +77,30 @@ abstract class Relation
return (new $this->model)->toCollection($resultSet);
}
/**
* 移除关联查询参数
* @access public
* @return $this
*/
public function removeOption()
protected function getQueryFields($model)
{
$this->query->removeOption();
return $this;
$fields = $this->query->getOptions('field');
return $this->getRelationQueryFields($fields, $model);
}
protected function getRelationQueryFields($fields, $model)
{
if ($fields) {
if (is_string($fields)) {
$fields = explode(',', $fields);
}
foreach ($fields as &$field) {
if (false === strpos($field, '.')) {
$field = $model . '.' . $field;
}
}
} else {
$fields = $model . '.*';
}
return $fields;
}
/**
@@ -105,10 +118,8 @@ abstract class Relation
$result = call_user_func_array([$this->query, $method], $args);
if ($result instanceof Query) {
$this->option = $result->getOptions();
return $this;
} else {
$this->option = [];
$this->baseQuery = false;
return $result;
}