Let us continue our work on the Students
controller and build an action that would retrieve information about all the students in our students table, present in the controllers/students.php
file:
public function get($id=null){ $this->view->student_data = $this->model->getStudents(); $this->view->render('students/get'); }
In this snippet, we are creating the get
action that retrieves student data. This action can be used to get information about a single student or information about all students.
Note
We are only handling the case about fetching information about all students; once the portal handles other profile information of the student, we can build a view for the student profile.
We are using the getStudents
method provided by our Students_model
to fetch the data and pass it on to the get.php
view in the students
subdirectory. Now let us take a quick look at the getStudents
method, present in the models/students_model.php
file:
public function getStudents...