I am trying to set up an order - item relationship. I have 3 tables; order, a linking table called order_item and an item table.
here is the relationship defined in the order model class:
‘items’ => array(self::MANY_MANY, ‘Item’, ‘order_item(order_id, item_id)’),
here is the relationship defined in the item class:
‘order_items’ => array(self::BELONGS_TO, ‘Order_item’, ‘item_id’),
Here is the code I am running:
$orders = Order::model()->with(‘items’)->findAll();
And here is the error I get
The relation "items" in active record class "order" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.
Can someone help me find what I am missing?
Thanks