I have defined a relational table MemberSchool. The fields in the table include college_id, senior_id, major_id, and three other tables, college, senior, major table. This is the code I used to query the language {code ...} now I want to use the Statement of the associated model to query their data... I have defined a relational table MemberSchool. The fields in the table include college_id, senior_id, and major_id.
There are three other tables: college, senior, and major.
This is the code I used to query the language.
$memberSchool = M('Memberschool');$where['member_id'] = array('EQ',$this->member_id);$result = $memberSchool->field('college_name,major_name,school_name') ->join('JOIN __COLLEGE__ ON __MEMBERSCHOOL__.college_id = __COLLEGE__.college_id') ->join('JOIN __SENIOR__ ON __MEMBERSCHOOL__.senior_id = __SENIOR__.id') ->join('JOIN __MAJOR__ ON __MEMBERSCHOOL__.major_id = __MAJOR__.major_id') ->where($where) ->find(); return $result;
Now I want to use the Statement of the associated model to query their data. How can I query it? Which table is used as the reference table?
Reply content:
I have defined a relational table MemberSchool. The fields in the table include college_id, senior_id, and major_id.
There are three other tables: college, senior, and major.
This is the code I used to query the language.
$memberSchool = M('Memberschool');$where['member_id'] = array('EQ',$this->member_id);$result = $memberSchool->field('college_name,major_name,school_name') ->join('JOIN __COLLEGE__ ON __MEMBERSCHOOL__.college_id = __COLLEGE__.college_id') ->join('JOIN __SENIOR__ ON __MEMBERSCHOOL__.senior_id = __SENIOR__.id') ->join('JOIN __MAJOR__ ON __MEMBERSCHOOL__.major_id = __MAJOR__.major_id') ->where($where) ->find(); return $result;
Now I want to use the Statement of the associated model to query their data. How can I query it? Which table is used as the reference table?