0

Sorry for the bad title, I have no idea how to call it otherwise.

My "Product" table has a HABTM-link set up with "ProductProperty".

Now, unfortunately, the client has decided every property could be added multiple times with different data.

So, I'm trying to save this:

array(
    array('product_id' => 8218, 'property_id' => 30, 'numeric_value' => 47, 'modifier' => 1),
    array('product_id' => 8218, 'property_id' => 30, 'numeric_value' => 21, 'modifier' => 1)
);

But of course, the last 2 values just overwrite the first 2. Any idea on how I can trick Cake into storing them separately?

Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
  • I don't see how the last 2 values overwrite the first 2. Because they are different on the 4th key. Which in the first case is equal to '1' and in the second case equal to '6'. So how do they overwrite each other? Can be a little bit more precise? :) – Jelmer Jan 29 '13 at 11:21
  • Right, I normalize the data before the save (because saving the data directly as I showed here would result in an empty record). So basically I save something *like* what I posted above. – Jelle De Loecker Jan 29 '13 at 11:35

1 Answers1

0

I saved the records directly to the table, (by using $P = ClassRegistry::init('ProductProperty'); and $P->saveMany($ProductProperties);)

Of course I had to delete all the existing records first.

Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142