views:

78

answers:

1

Hi,

I am using CakePHP framework with MySQL database and I have problem in saving one particular value to the database. I have a table called 'Attributes' with fields,id,form_id,label,type,size and instructions. When a link is clicked,default values are stored in the table for these fields.

Now I added a new column called 'required' to the Attributes table. Its value is either 0 or 1,so I initially created it as a binary field. But the stored in it was \0. So I changed it as integer value and tried to save a default value like 5. but the value stored in it is always 0,i.e.,the value doesn't change.

It seems silly,but I dont know the reason.I have given the function below. All the other field's value get stored except for the 'required' field. Please someone help me

   function saveFieldEntries($data)
   { 
      $this->data['Attribute']['form_id'] = $this->find('all', array(
            'fields' => array('Form.id'),
            'order' => 'Form.id DESC'
                                     ));
        $this->data['Attribute']['form_id']=$this->data['Attribute']['form_id'][0]['Form']['id'];

     $this->data['Attribute']['label']= 'Label';
        $this->data['Attribute']['size']='50';
        $this->data['Attribute']['instructions']='Fill it';
        $this->data['Attribute']['type']=$data['Attribute']['type'];
        $this->data['Attribute']['sequence_no'] = $data['Attribute']['sequence_no'];
        $this->data['Attribute']['required']='5';
        $this->Attribute->save($this->data);
}
+1  A: 

At a glance, your code looks fine. Is it possible you've got a cached version of the model so CakePHP still assumes the field's type is binary?

Try deleting the content of the /app/tmp/cache/models directory.

Botman
Yes you are correct. After I deleted the contents,the value is getting stored. Thank you.
Angeline Aarthi