A specific column is not being inserted when saving a record

只愿长相守 提交于 2019-12-02 10:49:59

问题


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.

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?


回答1:


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.




回答2:


Modifying

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

Refreshing a page and restoring

Config::write('debug'); 

to original value will also work.



来源:https://stackoverflow.com/questions/37388082/a-specific-column-is-not-being-inserted-when-saving-a-record

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!