Cakephp2。保存数据又增加了两行

时间:2017-09-20 13:21:23

标签: cakephp

public function index($tin=null) {
    $this->layout = 'index_1';
    $this->loadModel('Insurance');
    $this->loadModel('Verification');
    $this->loadModel('Insurance_price');

    $date = date('Y-m-d');
    $verification_fee=$this->Insurance_price->findByInsurance_type("Third Party Auto Insurance");
    $ver = $verification_fee['Insurance_price']['verification_amount'];
    if(!empty($tin)) {
        $this->request->data['tin'] = $tin;
        $this->request->data['amount'] = $ver;
        $this->request->data['date'] = date('Y-m-d');
        $this->Verification->save($this->request->data);
        $this->Verification->clear($this->request->data);
    }
}

那是我的控制者。我试图在页面加载后保存这些数据。

但是当我检查数据库表而不是只看到1个新记录时,我看到3个新行与'amount'和'date'具有相同的数据,除了锡柱将有'image'。

我可能做错了什么?

1 个答案:

答案 0 :(得分:0)

尝试插入

$这 - > Verification->创建();

之前

$这 - > Verification->保存($这 - >请求 - >数据);

并检查