保存记录时未插入特定列 [英] A specific column is not being inserted when saving a record

查看:99
本文介绍了保存记录时未插入特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 CakePHP 1.3.13

这里,deals数据库表如下所示。

Here, deals database table looks like below.

当我将记录插入数据库时​​,不插入voucher_code列。

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

这里,当我打印$ this-> data时,它会给出所有的数据,如:

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
    )

)

插入查询如:

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

因此,除 voucher_code 之外,所有列都被插入。那么会有什么错误呢?如何解决此错误?

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

推荐答案

只有存在于缓存数据库表模式中的那些列/ ,所以当CakePHP已经缓存它之后添加字段时,你必须清除缓存(delete app / tmp / cache / models ),

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.

这篇关于保存记录时未插入特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆