Monday, June 29, 2009

Re: 'add' action and auto-setting model id

Hi Vijay,
 
Have a look at the source of controller.php in constructClasses() and you will see what Ralph is experiencing. Line numbers are indicative of r8204 (current branch).
 
line 448:
$id = $this->passedArgs['0'];
 
line 452:
$this->loadModel($this->modelClass, $id);
 
Cheers,
Adam
----- Original Message -----
Sent: Monday, June 29, 2009 11:03 PM
Subject: Re: 'add' action and auto-setting model id

Hello Raph,

I think you are making a mistake that you are providing a id while adding a record.
If you provide the id to the save method it fires the update query.

For further explanation Can you please paste the code here?

On Mon, Jun 29, 2009 at 5:44 PM, Raph <rafal@epoczta.pl> wrote:

I have weird (I think) problem. When I've added "add()" action to the
contoller, the id of coresponding model has been set automaticlly to
"add()" method parameter, and when I try to save data using that
action update instead of save is made.

This method singature looks like this:

public function add($someId).

Is it normal behavior? Do I have to manually call "create()" method in
my model if I want to save, not update data?




--
Thanks & Regards,
Vijayk.
Co-founder (www.weboniselab.com)

"You Bring the Dreams, We'll Bring the Means"
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: