mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Model类的relation方法
This commit is contained in:
@@ -164,10 +164,17 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
/**
|
/**
|
||||||
* 获取关联模型实例
|
* 获取关联模型实例
|
||||||
* @access protected
|
* @access protected
|
||||||
* @return Relation
|
* @param string|array $relation 关联查询
|
||||||
|
* @return Relation|Query
|
||||||
*/
|
*/
|
||||||
protected function relation()
|
protected function relation($relation = null)
|
||||||
{
|
{
|
||||||
|
if (!is_null($relation)) {
|
||||||
|
// 执行关联查询
|
||||||
|
return $this->db->relation($relation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取关联对象实例
|
||||||
if (is_null($this->relation)) {
|
if (is_null($this->relation)) {
|
||||||
$this->relation = new Relation($this);
|
$this->relation = new Relation($this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user