Revision: 51727
Updated Code
at October 2, 2011 14:10 by shoelessone
Updated Code
//The basic example controller. This is the basis for the different examples Report_Controller { public function list_classroom($classroomNumber){ $data["classroomInfo"] = $this->classroom_model->getClassroomInfo($classroomNumber); } } Classroom_Model{ //We're going to do this a few different ways!! Exciting! $this->load->model("student_model"); $this->load->library("student_library"); public function getClassroomInfo($classroomNumber){ $classroomInfo = array(); $classroomInfo["classTitle"] = $this->db->query("SELECT....")....; $classroomInfo["teacher"] = $this->db->query("SELECT...")...; //FIRST WAY $classroomInfo["students"] = $this->student_model->getStudentsInClass($classroomNumber); //SECOND WAY!! $studens = array(); $studentIDs = $this->db->query("SELECT * FROM students_table WHERE classroom = $classroomNumber"); foreach($studentIDs as $studentID){ $students[] = new Student($studentID); } $classroomInfo["students"] = $students; return $classroomInfo; } }
Revision: 51726
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 2, 2011 13:04 by shoelessone
Initial Code
//
Initial URL
Initial Description
I am having a bit of trouble figuring out what goes where in my application. I guess this is something of a fundamental lack of understanding I have, and I'm hoping somebody might be able to clear things up. This is all very much pseudo code. In this example let's assume that I'm writing a program that keeps track of students grades, classroom attendance, etc. A school has a collection of classrooms, and a classroom has a collection of students. I'm going to create a basic controller, model, as well as another class I'll call Student. Please note that the point of this is that I'm not sure if the Student class should be there, or if the Student model should be all I use, or if the Student class should have it's own ability to access the DB. In this simple example I'm simply looking at the student, but the same questions could apply to the Classroom, the School, etc. AGAIN, THIS IS PSEUDO CODE SO THERE ARE A FEW PLACES THAT I AM WRITING GARBAGE CODE TO ASK A QUESTION!
Initial Title
CodeIgniter - basic question
Initial Tags
php, codeigniter
Initial Language
PHP