Welcome Guest, Not a member yet? Register   Sign In
Which Model
#1

[eluser]Unknown[/eluser]
Hi All,

Been searching the CI forums for an answer to this - found loads on models but not this particular (probably daft) question:-

Supposing I have a Model to deal with my students (adding a student, updating a student etc) and a Model to deal with courses (adding a new course, deleting a course etc.) If I wanted to code a new method to see if a student was enrolled on a particular course (by looking at a junction table between the users and courses tables in the database), which Model would be best candidate for housing this?

Thanks,
C
#2

[eluser]rogierb[/eluser]
Which courses does a student attend => student model => from point of student
Which students are in a course => course model => from point of course
Enroll a student in a course => course model => from point of course
A student wants to enroll in a course =>student model => from point of student

Or create a student_course model to house everything that has to do with both

To be honest, it doesnt really matter that much in this case. As long as you are comfortable with it.
#3

[eluser]Unknown[/eluser]
Thanks Rogierb - very helpful!
#4

[eluser]überfuzz[/eluser]
I'd go for both I guess. I can't really see the cross-section, looking at the semantic of the code...
Code:
$this->student->add_course();
$this->course->add_student();

Furthermore, I can't see any issues working with the same sql-table in different models.




Theme © iAndrew 2016 - Forum software by © MyBB