Название функции и сам код очень сложно читаем 😀 Тут мне кажется было легче все сделать через SQL чем городить такое 😬
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public static function getProByStuId($table) { $query=DB::query(Database::SELECT,"select * from course where PropertyId = 4 and courseId not in (select courseId from courseselection_stu where studentId = ".$_COOKIE['id'].")")->execute()->as_array(); for ($i=0;$i<sizeof($query);$i++) { $teachername = DB::query(Database::SELECT,"select teacher.name from courseselection_tea,teacher where courseselection_tea.courseId=".$query[$i]['courseId']." and teacher.teacherId = courseselection_tea.teacherId" )->execute()->as_array(); $query[$i]['teachername'] = ''; foreach ($teachername as $teachervalue) $query[$i]['teachername'] = $query[$i]['teachername'].$teachervalue['name']." "; $classinf = DB::query(Database::SELECT,"select workout_course.weeknum,workout_course.startsection,workout_course.endsection,classroom.Place from workout_course,classroom where workout_course.courseId=".$query[$i]['courseId']." and workout_course.classroomid = classroom.Id")->execute()->as_array(); $query[$i]['Place'] = ''; $query[$i]['weeknum'] = ''; foreach ($classinf as $classvalue) { $query[$i]['Place'] = $query[$i]['Place'] . $classvalue['Place'] . " "; $query[$i]['weeknum'] = $query[$i]['weeknum'] ."周".$classvalue['weeknum'].":".$classvalue['startsection']."-".$classvalue['endsection']."节;"; } } return $query; } |