9760

Problem in storing value in database

Question:

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); }

Answer1:

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.

Recommend

  • change color of jstree node
  • Is it possible to define rest argument in OCaml?
  • Subclassing QGraphicsItem prevents me from being able to use itemAt() on a QGraphicsScene/View
  • Selenium to click on a javascript button corresponding to a text
  • Does Mobilefirst provide a provision to access web services directly?
  • Detect when Facebook like button is clicked
  • Groovy: Unexpected token “:”
  • Keep this build forever option - Jenkins
  • Webgrid not refreshing after delete MVC
  • java inputstream
  • Converting a WriteableBitmap image ToArray in UWP
  • How to define and use opencv mat of user type
  • Replace value with Factor in r data.table
  • Jquery UI tool tip close icon
  • How to access EntityManager inside Entity class in EJB3
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Spring Data JPA custom method causing PropertyReferenceException
  • Is there any way to access browser form field suggestions from JavaScript?
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • Excel - Autoshape get it's name from cell (value)
  • Modifying destination and filename of gulp-svg-sprite
  • Cassandra Data Model
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Convert array of 8 bytes to signed long in C++
  • Hazelcast - OperationTimeoutException
  • GridView Sorting works once only
  • Numpy divide by zero. Why?
  • Traverse Array and Display in markup
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Understanding cpu registers
  • Getting Messege Twice Using IMvxMessenger
  • Qt: Run a script BEFORE make
  • Does armcc optimizes non-volatile variables with -O0?
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Converting MP3 duration time
  • Python/Django TangoWithDjango Models and Databases