Friday, April 20, 2012

Re: Query produced by $this->User->save($this->data); gives error

Thanks , 
 
  this worked .....

On Fri, Apr 20, 2012 at 14:13, stork <lubomir.stork@gmail.com> wrote:
Always call as first

$this->User->create(); //see the API

and then either

$fieldList = array(...);
$this->User->set($this->request->data);
$this->User->set('field', 'value');
$this->User->save(null, true, $fieldList);

or directly

$this->User->save($this->request->data, true, array(...));

Which fields will be saved, it is decided by combination of two factors - which fields are present in data, and which fields are specified in whitelist array. Usage of whitelist (3rd param of Model::save()) is good habit - if form fields are generated by FormHelper and controller uses SecurityComponent, you don't have to worry about form tampering in client's browser, but it is better/safer to tell model about desired fields anyway.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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



--
         マンゲシュサテ
     MANGESHSATHE
   

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: