5

here is my code

public function settings(){
$this->loadModel('Userinfo');

    $helpers = array('TimeZoneHelper');
    if($this->request->is('post')) {
        $id = $this->Auth->User('idUser');


 $data =  $this->request->data['Userinfo']['timezone'];
 $this->Userinfo->save($data,array(
     'conditions' => array('Userinfo.User_id' => $id))));

}

i have a field name timezone in my userinfo table .. which i want to update .. i dont know how can i specifically update the single field in Cakephp as i am new in Cakephp ..i am doing this but dont know why it isn't working ...well when i debug the $data .. the data is coming fine .. in database the datatype of timezone is "time"

hellosheikh
  • 2,929
  • 8
  • 49
  • 115
  • You aren't showing a lot of effort here - There are 10s if not 100s of duplicate questions of this kind of thing - and it's also covered by [the documentation](http://book.cakephp.org/2.0/en/models/saving-your-data.html) and the [blog tutorial](http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html). And it looks like you're just making code up (passing conditions to save? where have you seen that?). – AD7six Jun 28 '13 at 14:35

1 Answers1

9

Set you models id:

$this->Userinfo->id = $id;

Then, use the savefield function to save a specific field:

$this->Userinfo->saveField('timezone', 'UTC');

Good luck further on cakePhp!

stevekohls
  • 2,214
  • 23
  • 29
jmc
  • 312
  • 1
  • 11