Welcome Guest, Not a member yet? Register   Sign In
Outlet ORM
#14

[eluser]Unknown[/eluser]
[quote author="M4rc0" date="1259198194"]

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 Smile[/quote]

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.

Code:
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;
     }
}


Messages In This Thread
Outlet ORM - by El Forum - 10-31-2008, 12:42 PM
Outlet ORM - by El Forum - 11-03-2008, 02:05 PM
Outlet ORM - by El Forum - 03-12-2009, 10:05 AM
Outlet ORM - by El Forum - 03-13-2009, 12:10 PM
Outlet ORM - by El Forum - 04-22-2009, 08:56 AM
Outlet ORM - by El Forum - 10-28-2009, 08:54 AM
Outlet ORM - by El Forum - 10-29-2009, 04:04 PM
Outlet ORM - by El Forum - 11-17-2009, 03:55 AM
Outlet ORM - by El Forum - 11-17-2009, 05:13 AM
Outlet ORM - by El Forum - 11-17-2009, 08:39 AM
Outlet ORM - by El Forum - 11-17-2009, 02:43 PM
Outlet ORM - by El Forum - 11-18-2009, 01:47 AM
Outlet ORM - by El Forum - 11-25-2009, 01:16 PM
Outlet ORM - by El Forum - 07-08-2010, 08:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB