When you have no idea how is relationship works in SQL

Member

lou_lindgren

by lou_lindgren , in category: PHP , 2 months ago

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;
}

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers