Duplicate records are not getting added to HABTM table in cakephp2, Is this intended?

29 Views Asked by At

So in my proyect you can make purchases with have products in them, this is represented in my db by a HABTM association between them, the thing is, i prepare the array to save the data using $this->purchase->saveAll and if the purchase has a duplicate product in it it will only add that record once.

Here is the [array] enter image description here that im passing the saveAll() funtcion.

After that array gets saved the only records added to products_purchases are one for product_id 54 and one for product_id 15, as opposed to the two records i want from product_id 54 and the one for 15.

If i havent explained myself clearly, please, let me know.

0

There are 0 best solutions below