[Deprecated] DMZ 1.5.3 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
FYI: I charge $100/hour for consultation ;-P There are a lot of different ways to handle it. Most likely, it will involve having a single table that looks something like this: Code: " In this example, there is only one supervisor/boss per employee. If you want multiple bosses (e.g.: like Office Space), that requires a dedicated table for tracking those relationships. My DataMapper model might look like this: Code: class Employee extends DataMapper { This relationship is a little different, because I wanted to have $boss->employee list all of the employees for the Employee $boss. (I needed to show this, so I'm sorry if it is confusing.) Because of this, you'll notice there is less fields specified. Now let's add a new employee, and insert her between Susan and Joe (we always can use more middle managers, right? ;-) ): Code: $jane = new Employee(); Now, to get the supervisor or employees of a person, it's very simple: Code: $susan = $jane->supervisor->get(); If you want to see if you are at the head honcho, you could try: Code: $head_honcho = ! $person->supervisor->get()->exists(); One final example. Say you didn't want to use Employee->employee, you might have something like this: Code: class Employee extends DataMapper { Everything else stays the same! |
Welcome Guest, Not a member yet? Register Sign In |