Hi all,

I'm really stuck on something which i think should be very easy. I
have a

Product HABTM categorypropertyoption,

and everytime a product is viewed by the view() action, it should add
one to the value of Product['count_view'], but when i try:

$results['Product']['count_hits'] = $productinfo['Product']
['count_hits'] + 1;
$this->Product->save($results);

it just deletes all categorypropertyoptions belonging to the product,
and inserts them again incorrectly.
I tried to implement the <<ExtendAssociations Behavior>> from
http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior and
there was no problem adding and deleting associations, but i still am
not able to just update a field in the original Model without
destroying all associations.  I also tried to unbind() before save,
and i tried to just save the field with saveField().

I found one solution which is first adding the associations (there
already are) with

$this->Product->habtmAdd('Categorypropertyoption', $id,
$productinfo['Categorypropertyoption']);

before saving. I really don't like this solution, because every time a
product is viewed a new id is created for the association.

Is there anything which works better?

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

Reply via email to