Here's my problem: If the foreign key in the HABTM join table isn't unique and could therefore return multiple matching records, all the records should be part of the returned dataset. The way it works now, only the first record is returned and the others are skipped.
Simple example: Model "pallet" HABTM "product" with join table "pallets_products" Example pallets_products data: pallet_id, product_id, quantity 1, 1, 10 1, 2, 10 1, 2, 15 Here pallet_id 1 has three lines in the join table although two of the lines are actually the same product_id but with a different quantity. This causes the following problem: $pallet = $this->Pallet->find('all', array('conditions'=>array ('Pallet.id'=>$id))) The code above produces the following (correct) SQL: SELECT `Product`.`id`, `Product`.`description`, `PalletsProduct`.`id`, `PalletsProduct`.`pallet_id`, `PalletsProduct`.`product_id`, `PalletsProduct`.`quantity` FROM `products` AS `Product` JOIN `pallets_products` AS `PalletsProduct` ON (`PalletsProduct`.`pallet_id` = 1 AND `PalletsProduct`.`product_id` = `Product`.`id`) WHERE 1 = 1 The above SQL statement correctly returns THREE lines - one for every matched line in the join table. However, the $pallet array produced only contains TWO matched lines from the join table. It skips the subsequent line which has product_id of 2. What gives here? Some say I have bad DB design (I don't believe so), others say this is how it should be (I also don't believe so). Interestingly the same issue has been raised as a ticket some 10 months ago but from reading the ticket I feel that the cake team didn't bother to understand what it meant and preferred just to close it (https://trac.cakephp.org/ticket/5128). I even discussed this briefly with mark story but he didn't seem interested in actually understanding the problem preferring instead to just tell me that I was "doing something wrong". Ho hum. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---