Интересная статическая функции в php получения всех курсов

Пользователь

от herbert , в категории: PHP , 3 года назад

Интересная статическая функции в php получения всех курсов


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public  static  function getAllCourseByTeacherId()
{
    $b=$_COOKIE['id'];
    $sql=DB::query(Database::SELECT,"select workout_course.courseid,weeknum,startsection,endsection,startweek,endweek,Place 
                        as classname,course.testtime,course.credit,course.name,course.capacity,course.margin,course.campus,college.name 
                        as collegeId,course.property,course.classhour,course.direction,teacher.name as teachername
                        from workout_course,classroom,course,courseselection_tea,teacher,college
                        where classroomid=classroom.Id and course.courseId=workout_course.courseid
                        and courseselection_tea.courseId=workout_course.courseid
                        and teacher.teacherId=courseselection_tea.teacherId
                        and course.collegeId=college.collegeId
                        and workout_course.courseid in (select courseselection_tea.courseId from courseselection_tea where 
                        courseselection_tea.teacherId=$b)")->execute()->as_array();
    // $a[0]=$sql[0];
    $k=0;
    $x=0;
    $i=0;
    while($k<sizeof($sql))
    {

        if ($sql[$i]['courseid'] != -1) {
            $a[$x] = $sql[$i];
            $a[$x]['time']="周".$sql[$i]['weeknum'].','.$sql[$i]['startsection']."~".$sql[$i]['endsection']."节;";
            $a[$x]['classname']=$sql[$i]['classname'].";";
            $a[$x]['startend']="第".$sql[$i]['startweek']."~".$sql[$i]['endweek']."周;";
            for ($j = $i + 1; $j < sizeof($sql); $j++) {
                if ($sql[$i]['courseid'] == $sql[$j]['courseid']) {
                    $a[$x]['time']=$a[$x]['time']."周".$sql[$j]['weeknum'].','.$sql[$j]['startsection']."~".$sql[$j]['endsection']."节;";
                    $a[$x]['classname']=$a[$x]['classname'].$sql[$j]['classname'].";";
                    $a[$x]['startend']=$a[$x]['startend']."第".$sql[$j]['startweek']."~".$sql[$j]['endweek']."周;";
                    $sql[$i]['courseid']=-1;
                    $k++;
                    $i=$j;
                }
            }
            $sql[$i]['courseid']=-1;
            $k++;
            $x++;
            $i=0;
        }
        else{
            $i++;
        }

    }
    return $a;
}


Facebook Vk Ok Twitter LinkedIn Telegram Whatsapp Pocket

Нет ответов