-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_institutions.php
More file actions
41 lines (29 loc) · 955 Bytes
/
Copy pathremove_institutions.php
File metadata and controls
41 lines (29 loc) · 955 Bytes
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
<?php
//run indefinitely
set_time_limit(0);
//db configuration
require_once 'database.php';
$institutionIds = array(1);
$subjects = ORM::for_table('subjects')->where_in('institution_id', $institutionIds)->find_many();
foreach ($subjects as $subject) {
$courses = ORM::for_table('courses')->where('subject_id', $subject->id)->find_many();
foreach ($courses as $course) {
// delete course slots
ORM::for_table('course_slots')->where('course_id', $course->id)->delete_many();
// delete course
$course->delete();
}
// delete subject
$subject->delete();
}
// delete institutions
ORM::for_table('institutions')->where_in('id', $institutionIds)->delete_many();
// clean instructors
$instructors = ORM::for_table('instructors')->find_many();
foreach ($instructors as $instructor) {
$course_slot = ORM::for_table('course_slots')->where('instructor_id', $instructor->id)->find_one();
if (!$course_slot) {
$instructor->delete();
}
}
?>