Before any advice to read google and etc, i must write that i read a lot of articles and blogs, and for now i cant figure out how to use HABTM in my case... ;]
I have order system with 3 tables and 3 models:
- ORDERS (order_id, customer_id, paymenyOption, etc...)
- ITEMS (item_id, size, color, etc...)
- CUSTOMERS (customer_id, name, telephone, etc...)
For now i have relationship between ORDERS<->CUSTOMERS (which works fine), but i need to have 'link table' in which will be order_id
, product_id
, quantity
.
To be clear,
one order can have many items
one items can be in many orders
one customer can have many orders (but one order can have one customer)
(normal order-system philoshopy)
In order view i must have details for 'item', 'customer', and 'order', something like:
Name: Johny Deep (from CUSTOMERS model)
Date ordered: 13-08-2013 (from ORDERS model)
Products: 2x apple, 2x watermelon (from ITEMS model)
I dont know if i must use hasMany or hasAndBelongsTo, and make another model for 'link table'?
Can anyone explain me this beautiful sh** in cakephp 2.x ? ;-)