• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Models that use other models? array of models? objects?? a case study

#1
[eluser]avastreg[/eluser]
Hi guys, i've just get into codeigniter and MVC, very good work!

I'd want to know what is the best way to solve my problem thinking with MVC pattern, and to find the best practices in these cases.

Let's start with the description of my case of study:

I have to list in my app many products. Every products is a record of table products, who has as fields id and name of the product. On a product user can do many actions, like add for the first time the product, re-add the product, consider shipped/unshipped that etc. I have a related table for this, called my_product_actions, on which i have as fields an action, a product_id (foreign key to products table), date of the action etc.

Now, theoretically, i think that the best way to retrieve and show products in OOP methodology is to build a class named Product, with gets the data from both tables, so when i get a product i can have the actions' history of that product, it's name etc.

I retrieve only the subset of products I'm interested in, instantiating so many Product objects as i need.

In MVC, what's the best way to achieve it?

Ok, i can transform the Product class into a Product_model.

But then?? I have to create another model, called Products_model, who call various instances of Product_model??

Or i have to call directly the Product_model from the controller? And, in that case, i need more products, one model is not enough!

Please, give me your feedback, because i don't have a clear idea to do this with MVC pattern.


Messages In This Thread
Models that use other models? array of models? objects?? a case study - by El Forum - 05-03-2009, 09:19 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.