M4rc0 - 25 November 2009 08:16 PM
How would the model look like in this “repository” pattern? Is this the same as a “Domain Driven Design” pattern?
I’m just trying to imagine the model after you presented the controller 
This is how I would do it. I was taught that all DB calls are done in the model. The controller and views should not have to request anything from the DB. Might not be the best way, but it works for me.
class OrderController extends Controller
{
function show($id)
{
// display order data...
$data['order'] = $this->order_model->getOrderById($id);
$this->load->view('showOrder', $data);
}
}
// in the model file Order_model.php
class order_model extends Model
{
function getOrderById($id)
{
$this->load->outlet();
$outlet = Outlet::getInstance();
$order = $outlet->load('Order', $id);
// Normally, I'd validate to make sure I have something to return
return $order;
}
}