A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearWhat is the best code location to define table relationship methods using Zend Framework models? - page 1
User InfoPosts
What is the best code location to define table relationship methods using Zend Framework models?#1
I'm creating a simple tag system that allows me to link a tag to almost everything in my application. In order to facilitate this, I created a table called "objects", referenced by my model "Object".

I've got three models setup at the moment:


Tag (with TagObject defined as a
dependentTable)
Object (with TagObject defined as a dependedTable)
TagObject (with both Tag and Object defined in the referenceMap)


I already created some simple methods like fetchTagById() and fetchTagByName() in my Tag model, but now I want to create a method that gets my tags and their respective occurences in the objects table, in order to create a simple tag cloud.

Structure-wise, what is the best location to create this method (using findDependentRowset())?

I somehow feel it is not very good practise to store this in my Tag model, but storing it in my TagObject model seems awkward too, and might overcomplicate things.

Any advice would be greatly appreciated.

Thanks in advance.

posted date: 2008-12-24 01:41:00


Re: What is the best code location to define table relationship methods using Zend Framework models?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-24 01:41:01


Re: What is the best code location to define table relationship methods using Zend Framework models?#3
If the method retrieves the tags, then it should be in the tag model. If it retrieves objects, it should be in the object model. Since you are retrieving tags and their occurrences, it should be in the tag model.I would call the model Tags not Tag, since Tag is a Row in Tags and in the ZF the model is usually a DataGateway to a table. Same with objects.$tags = new Tags();$cloud = $tags -> getWithObjectOccurrences();On another note, I would never name a class "object" or "objects" as it is too generic (objects are a basic language construct). Consider finding a more descriptive name for it.

posted date: 2008-12-24 02:01:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.