Welcome Guest, Not a member yet? Register   Sign In
Get image url from model good practice?
#4

(This post was last modified: 11-10-2015, 01:53 AM by sebastianvirlan.)

(11-10-2015, 01:16 AM)Martin7483 Wrote: In the world of MVC each request is routed to a Controller. You could ignore the M and V completely and do everything in your controller. But you will quickly see that this means duplicating a lot of code. So you start to use Models for Database communication. In your models you perform some logic to the DB results and return it to your controller. Again you will start to notice code duplication. So you start using helpers for common functions and libraries for more complex data handling. And thus you may start to use a business layer for your models.

I would say your Product class is a library and you pass a data package to this class. So how you call this could be
1. Controller --> request data from your model and return to Controller
2. Controller --> pass the data to the Product class and return to Controller
3. Controller --> pass the data to the view

Hopes this helps you out

Thank you. Helped a lot, see my last post with my class and tell me if I can refactor something.

Then in my controller I have:

PHP Code:
$best_offer         = new Product($this->products->best_offer(), 270);
$produse_noi        = new Product($this->produse->entries_by_limit(010null), 270);
$data['best_offer'] = $best_offer->product();
$data['produse_noi']= $produse_noi->products(); 

Is this the best practice MVC and OOP?
Reply


Messages In This Thread
RE: Get image url from model good practice? - by sebastianvirlan - 11-10-2015, 01:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB