Nisarg Bhavsar
Nisarg Bhavsar

Reputation: 956

A specific column is not being inserted when saving a record

I am working with CakePHP 1.3.13. Here I have writen a code to insert form in to database.

Here, deals database table looks like below.

enter image description here

When I insert record into database so voucher_code column is not inserted.

Here when I print $this->data then it will gives all data like :

Array
(
[Deal] => Array
    (
        [title] => Deal title
        [original_price] => 350
        [discount] => 45
        [total_price] => 192.5
        [voucher_code] => TEST3211
        [redeem_points] => 158
        [deal_details] => tetert
        [condition] => Testing
        [deal_address] => tertre
        [deal_end_date] => 2016-05-26
        [no_of_deals] => 10
        [merchant_id] => 24
        [image] => 146399768856085.jpg
    )

)

Here I have write insert query like :

 $this->Deal->create();
 $this->Deal->save($this->data);

So all column's are inserted except voucher_code. So what will be the error ? and How can I resolve this error?

Upvotes: 1

Views: 407

Answers (3)

Ashish Gaur
Ashish Gaur

Reputation: 77

this is very common issue goto tmp folder of your project and delete all the cache under model and persistent folder and re run your query and it start works.

Upvotes: 0

ndm
ndm

Reputation: 60463

Only those columns/fields will be saved that are present in the cached database table schema, so when adding fields after CakePHP has already cached it, you'll have to clear the cache (delete app/tmp/cache/models) in order for the new columns to be recognized.

Upvotes: 3

Sandeep Reddy
Sandeep Reddy

Reputation: 121

Modifying

app/Config/core.php 
Config::write('debug',2); 

Refreshing a page and restoring

Config::write('debug'); 

to original value will also work.

Upvotes: 1

Related Questions