public function get_student_courses($order = null)
 {
     LoadHelper::model('course');
     $student_list = array();
     //connect to database
     $this->db->connect();
     //query
     $sql = "SELECT s.id,s.first_name,s.last_name,s.email,s.contact_no,c.id as course_id,c.course_name ";
     $sql .= " FROM students s JOIN courses c on s.course_id=c.id";
     if (isset($order)) {
         $sql = $sql . " ORDER BY " . $order;
     }
     //fetchquery
     $result = $this->db->fetchquery($sql);
     while ($row = $result->fetch_assoc()) {
         $student = new Students();
         $student->set_id($row['id']);
         $student->set_first_name($row['first_name']);
         $student->set_last_name($row['last_name']);
         $student->set_email($row['email']);
         $student->set_contact_no($row['contact_no']);
         $course = new Course();
         $course->set_id($row['course_id']);
         $course->set_course_name($row['course_name']);
         $student->set_course($course);
         array_push($student_list, $student);
     }
     $this->db->close();
     return $student_list;
 }
 public function get_all($order = null, $where = NULL)
 {
     $course_list = array();
     //connect to database
     $this->db->connect();
     //query
     $sql = "SELECT * FROM courses";
     if (!is_null($where)) {
         $sql = $sql . " WHERE " . $where;
     }
     if (!is_null($order)) {
         $sql = $sql . " ORDER BY " . $order;
     }
     //fetchquery
     $result = $this->db->fetchquery($sql);
     while ($row = $result->fetch_assoc()) {
         $course = new Course();
         $course->set_id($row['id']);
         $course->set_course_name($row['course_name']);
         $course->set_added_date($row['added_date']);
         $course->set_status($row['status']);
         array_push($course_list, $course);
     }
     $this->db->close();
     return $course_list;
 }
예제 #3
0
 private function map_data()
 {
     $Course = new Course();
     $Course->set_course_name($_POST['course_name']);
     $Course->set_status($_POST['status']);
     return $Course;
 }
 public function get_all()
 {
     $course_list = array();
     $sql = "SELECT * from course";
     $this->db->connect();
     $result = $this->db->fetch_query($sql);
     while ($row = $result->fetch_assoc()) {
         $course = new Course();
         $course->set_id($row['id']);
         $course->set_course_name($row['course_name']);
         $course->set_duration($row['duration']);
         $course->set_status($row['status']);
         array_push($course_list, $course);
     }
     return $course_list;
     $this->db->close();
 }