I have defined a relational table Memberschool, which contains the fields college_id,senior_id,major_id
There's another three tables college,senior,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 association model to query their data out, how to query it? Which table do you want to use as a reference table?
Reply content:
I have defined a relational table Memberschool, which contains the fields college_id,senior_id,major_id
There's another three tables college,senior,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 association model to query their data out, how to query it? Which table do you want to use as a reference table?