He said that if there is a membership table, each member has to invite a person from_id field (record of the member who invited), know that a member id, and now need to check whether a particular member of the member of subordinates.
Table is as follows:
First, the needs of the moment
1, we need to know members id5 Zhao money, if Joe Smith is a member id affiliated members.
2, Code of ideas, check up from the lower levels, because a person can only have one parent. Recursive query, the query to a higher level, to judge, to meet is returned. Not satisfied to get a new higher level, research has been to meet or query, there is no supervisor or member, complete the membership records of all inquiries.
3, as follows
/** * Determine whether the members of the lower level is another member * @Param [type] $ member_id system head id * @param [type] $other_member_id 下级id * @return [type] * / Function getInfo ( $ member_id , $ other_member_id ) { // lower member information id $ from_info = $ the this -> findMemberData ([ 'id' => $ other_member_id ], 'id, from_id' ); // Member of invite people id assignment $ uid = $ from_info [ 'from_id' ]; the while ( $ uid > 0) { // have to invite people to judge, that is to meet the return true; otherwise up to research, has been found not invite people up to $ from_info = $ the this -> findMemberData ([ 'ID' => $ UID ], 'ID, from_id' ); IF ( $ from_info['from_id'] == $member_id){ return 1; } The else { // not satisfied, the re-assignment $ UID = $ from_info [ 'from_id' ]; } } return 0; }