0

Let´s say I have a schema containing 3 tables: Users,Pages and Followers. An user can follow many pages. The followers table would contain the page_id and user_id.

I need to create a method to return all the users following a page.. Should i create the method in the PageTable class ($page->getFollowers()) or should i create a method in the followersTable class $followers->getByIdPage($id).

In a pure OO application the first approach makes more sense and also feels more natural but since symfony/doctrine creates also a class for the relationship tables I dont know.

The approach i am trying to follow in my app each table class should only return objects from the table related to that class. Example: All the methods in the page class should return Page objects. By this approach if I put the method in followers class I shold only return objects of that class and not Pages objects thats what i need.

Any thoughts about this?

brpaz
  • 3,618
  • 9
  • 48
  • 75
  • It's the matter of approach. You have one in your application, so just follow it. Voting to close as non-constructive. – J0HN Sep 25 '11 at 07:08

1 Answers1

0

You should create the method getFollowers() in Page class. It makes sense because you want the followers of an object page.

PageTable class should return a Collection of Page object.

arsenik
  • 987
  • 2
  • 8
  • 22