为了说明问题,假设现在有表test1,test1有从表test2:test1属于test3,test1和test4多对多,关联表test1_test4. 1.定义关系 class Test1Model extends WdModel { public function test2(){ return $this->hasOne('Test2','test1_id'); } public function test3(){ return $this->hasMany('Test3','test1…