Search the Community
Showing results for tags 'model'.
-
Hi everyone, So I'm relatively new to OO PHP and moreover, OO PHP with MVC design pattern. This may be a largeish post so please bear with me on this one! So here is a scenario that I'd like to understand. There are likely multiple ways to go about this, but it'd be nice to see what is said. I'll include what I think should be the solution here and hopefully i'll get some feedback about it. Scenario: A page needs to display a list of "parts" for a car. A database table already exists with these parts. The list of parts on the page need to be ordered by name on first load, but then can be re-ordered by users using a drop down list. They can also be filtered, and searched. A page also exists to display a single car part. What I think should be, and what i'm struggling with: Model: I will have a "part" object which represents an individual car part. The part object will use a database abstraction layer. On "new Part()" will generate an empty object. ->Load( id ) will load an individual part. Controller: I do not know how I would implement this. I know it would contain methods to Filter(), Search() and Order() and that would directly access the Model. View: I am lost here too, I need to display a list of car parts, and on another page, a single car part. I understand I should use the same Model for both. However I do not see how I would list the parts. Some Questions: Should I have another "model" that is a list of the "Part" model called PaetListModel, or should "Part" be able to generate that list? I clearly should have 2 views, one for singular part, one for list of parts. Should the view access the model to generate the list before using the data for output? Should the controller be used in the view instead of the model to generate the initial list (or singular) on page load? Should the filter functions in the controller reload the "PartsList" from wherever our list is stored? I think the most important question for me though is: How would YOU implement the above green scenario? I would like to learn from peoples examples so I get an idea of what road to follow
- 1 reply
-
- mvc
- design pattern
-
(and 3 more)
Tagged with:
-
For the past few years, I have been designing a database & web site for a client in quite a mediocre style IMO. The site design is something that can always be changed, modified, and more or less completely overhauled. My question is in the database design. Since I am by no means an expert Database Administrator, I have been approaching my clients site with a very novice approach. One table per product type. Every product type has several similar attributes like colorname, stylename, price, etcetera... Yet every product type also has way more distinct attributes, like thickness, edge profiles, cleaning methods, installation methods, etcetera. I have googled around and came across something called the EAV Model. When I first saw it I was stricken with awe.. and thought to myself that THIS was the answer to all of my problems............ a few google searches later, I hear nothing but horrible things about this model when it comes to SEO.. or in-site searches in general. It is supposedly a nightmare of a "Normal Form" to use for something whose rows will be populated exponentially. 40 new products one day, 22 the next, 100 another day... and so on. So my question, which I almost feel deserves to be in Application Design... is What is the ideal method of normalization for a database that contains several product types which have both similar and dissimilar attributes? Obviously a table for every product type is ridiculous and inefficient, because the owner constantly has a new attribute he wants to add causing me to have to hack and tweak and duct tape it into the system. I really need some advice if I want to do this for a living or be able to claim that I know what I am doing when it comes to e-commerce website development. Luckily, I convinced the client to go with Authorize.net so I do not have to create a shopping cart, but that is another story completely.
-
Hi Guys, I have been playing around with zend 2 and all going well, as I am sure you are aware the documentation is still in its early stages and is incomplete in some places. The problem I have got is I am trying to find the correct way to populate the options of a select element from a model using the zend table gateway method. I got this working fine using doctrine, but decided to try the gateway way aswell, and I have to admit it has me a little stumped. Do any of you have an example of this, or a good reference for it? thanks
-
- zend framework 2
- form
-
(and 2 more)
Tagged with: