开发者

symfony 1.4/ doctrine 1.2 active record relationship tables code organize

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 tabl开发者_开发百科es 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜