class cart_m_cart extends a_base_model_datamapper { public function __construct($id=null) { $this->table = 'carts'; $this->has_many = array( ); $this->has_one = array( ); $this->has_many['item_m_cart'] = array( 'class' => 'item_m_cart', 'join_other_as' => 'item', 'join_self_as' => 'cart' ); parent::__construct($id); } }
public function __construct($id=null) { $this->table = 'cart_items'; $this->has_many = array( ); $this->has_one = array( ); $this->has_one['cart_m_cart'] = array( 'class' => 'cart_m_cart', 'join_other_as' => 'cart', 'join_self_as' => 'item' ); parent::__construct($id); } }
$c = new cart_m_cart(); $c->user_id = 2; $c->site_id = 2; $c->get(); $ci = new item_m_cart(); $ci->product_id = 1; $ci->qty = 5; $c->save($ci);