Hi casualman
you can try this
function afterSave($created){
if($created){
$diary_id = $this_id;
$projects
=
$this->Project->find('all',array('conditions'=>array('Project.id'=>$diary_id)));
$price_worked = $this->price_worked;
$price_left = $projects['Project']['price_left']
- $price_worked;
*$this->Project->id = $diary_id;*
$this->Project->save($projects);
}
}
On Mon, Dec 13, 2010 at 6:40 PM, casualman <[email protected]> wrote:
>
> Hi Amit
>
> Thank you for your response. This is what I needed. But I am very new to
> cakePHP, i have tried implementing the afterSave() function but it adds a
> new record to the other model I want to update. Here is the code, coudl you
> please tell me what I am doing wrong:
>
> function afterSave($created){
> if($created){
> $diary_id = $this_id;
> $projects =
>
> $this->Project->find('all',array('conditions'=>array('Project.id'=>$diary_id)));
> $price_worked = $this->price_worked;
> $price_left = $projects['Project']['price_left'] -
> $price_worked;
> $this->Project->save($projects);
> }
> }
>
> Kind Regards
> Thank you
> --
> View this message in context:
> http://cakephp.1045679.n5.nabble.com/Saving-to-one-model-while-updating-another-tp3301880p3302988.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
> more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
--
http://pulsaplusplus.com/~iwan
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 [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