模型注释

This commit is contained in:
yunwuxin
2017-01-23 13:46:17 +08:00
parent 8311a4e39b
commit 6078d0ea39
11 changed files with 402 additions and 340 deletions

View File

@@ -11,6 +11,7 @@
namespace think\model\relation;
use think\db\Query;
use think\Loader;
use think\Model;
@@ -19,11 +20,11 @@ class HasOne extends OneToOne
/**
* 架构函数
* @access public
* @param Model $parent 上级模型对象
* @param string $model 模型名
* @param Model $parent 上级模型对象
* @param string $model 模型名
* @param string $foreignKey 关联外键
* @param string $localKey 关联主键
* @param string $joinType JOIN类型
* @param string $localKey 关联主键
* @param string $joinType JOIN类型
*/
public function __construct(Model $parent, $model, $foreignKey, $localKey, $joinType = 'INNER')
{
@@ -37,16 +38,16 @@ class HasOne extends OneToOne
/**
* 延迟获取关联数据
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包查询条件
* @access public
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包查询条件
* @return array|false|\PDOStatement|string|Model
*/
public function getRelation($subRelation = '', $closure = null)
{
// 执行关联定义方法
$localKey = $this->localKey;
if ($closure) {
call_user_func_array($closure, [ & $this->query]);
call_user_func_array($closure, [& $this->query]);
}
// 判断关联类型执行查询
return $this->query->where($this->foreignKey, $this->parent->$localKey)->relation($subRelation)->find();
@@ -55,7 +56,7 @@ class HasOne extends OneToOne
/**
* 根据关联条件查询当前模型
* @access public
* @param mixed $where 查询条件(数组或者闭包)
* @param mixed $where 查询条件(数组或者闭包)
* @return Query
*/
public function hasWhere($where = [])
@@ -80,10 +81,10 @@ class HasOne extends OneToOne
/**
* 预载入关联查询(数据集)
* @access public
* @param array $resultSet 数据集
* @param string $relation 当前关联名
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @param array $resultSet 数据集
* @param string $relation 当前关联名
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @return void
*/
protected function eagerlySet(&$resultSet, $relation, $subRelation, $closure)
@@ -129,10 +130,10 @@ class HasOne extends OneToOne
/**
* 预载入关联查询(数据)
* @access public
* @param Model $result 数据对象
* @param string $relation 当前关联名
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @param Model $result 数据对象
* @param string $relation 当前关联名
* @param string $subRelation 子关联名
* @param \Closure $closure 闭包
* @return void
*/
protected function eagerlyOne(&$result, $relation, $subRelation, $closure)