When you have no idea how is relationship works in SQL π
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public static function getStudentById($data) { $query = DB::select() ->from('student')->where('studentId','=' ,$data) ->execute()->as_array(); $queryA = DB::select() ->from('major')->where('majorId','=' ,$query[0]['majorId']) ->execute()->as_array(); $queryB = DB::select() ->from('college')->where('collegeId','=' ,$queryA[0]['collegeId']) ->execute()->as_array(); $query[0]['majorName']=$queryA[0]['name']; $query[0]['collegeName']=$queryB[0]['name']; return $query; } |