PHP Mapper Template for Link Tables

I am finally embracing using the Mapper design pattern to structure the object oriented system I am building in PHP.

I have the type of classes User

and Project

each of which has a corresponding MySQL table (and Mapper classes, for example ProjectMapper

, UserMapper

)

What I want to know is the approach to link tables when using this template. I have another class Invitation

that invites User

to work with Project

. (This is just a standard table of links with project_id

and user_id

).

Let's say I want to get a collection of all users assigned to a specific project, firstly, where should this feature go? ProjectMapper

class, InvitationMapper

class?

And secondly. how can i make it neat and sane?

Thanks in advance.

+3


source to share


1 answer


Just take a look at this very interesting article - it helped me a lot when I was working on my own model, which should be efficient and easy to use:

http://www.survivethedeepend.com/zendframeworkbook/en/1.0/implementing.the.domain.model.entries.and.authors

The author explains how to create a robust model in Zend Framework, but you can use his ideas in other frameworks as well, or just create your own model without any frameworks.



I also recommend that you (if you are working with Zend) skip the testing parts - the topic itself is very complex and testing can be done when you are done with your model.

Building my own model, I've changed a few things, so if you have further questions - you know - feel free to ask them;)

0


source







All Articles