1 // 在a model定义b model关联
2 public function hasManyB()
3 {
4 return $this->hasMany('关联模型b的模型名');
5 }
6 // 在b model定义c model关联
7 public function hasManyC()
8 {
9 return $this->hasMany('关联模型c的模型名');
10 }
11 // 在a model中执行查询
12 $result = $this->with(['hasManyB' => ['hasManyC']])->where($where)->order($order)->select();
- // 在a model定义b model关联
- public function hasManyB()
- {
- return $this->hasMany('关联模型b的模型名');
- }
- // 在b model定义c model关联
- public function hasManyC()
- {
- return $this->hasMany('关联模型c的模型名');
- }
- // 在a model中执行查询
- $result = $this->with(['hasManyB' => ['hasManyC']])->where($where)->order($order)->select();