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