title: 1 to Many relationship in OOP php
body: <p>I need a little guidance before I spend a few hours restructuring and find out that this isn't a good way to do something.  My program is for a 1 to 1 initiative in a school district.  I have a database of all the assignments, the student, and the computers.  I am building an object oriented design to make coding some things more uniform (and for all the other benefits).  This application will be used to guide a user through the takeup and laptop check process.  Here is my dilemma.</p>
  
  <p>A student (object) can have one or two current assignments (one being a loaner the other a permanent).  I initially built a student object, an assignment object, and a device object.  Then, when the student is created we use a lookup factory to find the current assignment(s) that student has outstanding.  I then loop through these from within the student construct and create an array of assignment objects which each looks up the device information.</p>
  
  <p>This works great and gets all of the information that I need but I am finding it difficult to work with since there is an array of assignment objects and there are certain rules to follow logically.</p>
  
  <p>A loaner assignment (one given when the original computer has been sent off for problems) must be turned in FIRST. And, in general, it gets difficult to determine which assignment object in this array has properties I need to know.</p>
  
  <p>So, my IDEA (which may not be a good idea) is to break this out to a 1 to 1 to 1 to 1 relationship.  Student to assignments to assignment to device.</p>
  
  <p>Then if I need to know if the student has a loaner assignment I could make a function inside the assignments object and call <code>student-&gt;assignments-&gt;hasLoanerAssignment()</code></p>
  
  <p>What do you think internet?</p>