Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CAKEPHP - I'm trying to input data from FORM to Database, but is not working [duplicate]

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?

like image 415
Nisarg Bhavsar Avatar asked Nov 19 '25 15:11

Nisarg Bhavsar


2 Answers

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.

like image 171
ndm Avatar answered Nov 22 '25 04:11

ndm


Modifying

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

Refreshing a page and restoring

Config::write('debug'); 

to original value will also work.

like image 40
Sandeep Reddy Avatar answered Nov 22 '25 05:11

Sandeep Reddy