That sounds like one table too many to me. You can get what you want by doing 
simple finds, made even easier by using the containable behaviour, IMO.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 10 Aug 2010, at 11:26, Felix wrote:

> Thanks, Jeremy, Andras - I think I've worked it out now,
> 
> I wanted to keep the HABTM relationship so I could easily list all the
> products in an order and find all the orders a particular product is
> listed in, the HABTM seems the easiest way to do it so I'll leave that
> as it is. I've added an additional table to store the quantity and
> other info.
> 
> Thanks for your quick replies,
> 
> Felix
> 
> On Aug 9, 6:59 pm, Andras Kende <and...@kende.com> wrote:
>> Felix,
>> 
>> for a simple cart not sure if habtm is needed...
>> 
>> could be:
>> 
>> products
>>         id | name | description | image | price | qty
>> 
>> orders
>>         id | name | address | grandtotal | tracking | status |
>> 
>> order hasmany orderi_tems
>> 
>> order_items
>>         id | order_id | product_id | qty | price |....etc...
>> 
>> order_items belongsto order , product
>> 
>> Andras Kendehttp://www.kende.com
>> 
>> On Aug 9, 2010, at 12:27 PM, Felix wrote:
>> 
>> 
>> 
>>> Hi, I was wondering if anyone can help with a problem I'm having.
>> 
>>> I'm building a simple shopping cart system for which I have two
>>> objects
>> 
>>> 1. Product (stores product details - name, cost, SKU, etc.)
>> 
>>> 2. Order (Stores order details - customer address, shipping type,
>>> etc.)
>> 
>>> In the database these are joined using the table, orders_products.
>> 
>>> Cake correctly recognises the HABTM relationship between the two, so
>>> far so good.
>> 
>>> What I'm now stuck at is how to incorporate a quantity variable.
>> 
>>> Each product in an order must have a quantity but I don't know where
>>> to put it,
>> 
>>> I don't think it belongs in the products table or the order table, so
>>> the only place I can think of is in the join table (orders_products).
>> 
>>> If I add this field in how would I then set or read its value, seeing
>>> as it has no model I don;t know how to address it.
>> 
>>> The join table does show up when baking so I could add one, but I
>>> don't know if this would mess up the HABTM between the product and
>>> order models, and if it does what relationships I need to define in
>>> the relevant models to resolve such issues.
>> 
>>> I may of course be missing something or asking a very stupid question,
>>> in which case sorry but could you point out my idiocy!
>> 
>>> Thanks, Felix
>> 
>>> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> with their CakePHP related questions.
>> 
>>> You received this message because you are subscribed to the Google Groups 
>>> "CakePHP" group.
>>> To post to this group, send email to cake-php@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
>>> athttp://groups.google.com/group/cake-php?hl=en
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to