doulu6314 2017-01-07 05:58
浏览 91
已采纳

使用saveField函数或cakephp中的其他函数插入多个值

I insert multiple values into my database using saveField function. Here is my code.

$this->Fuel->saveField(
    'device_id',    $int_fuel_func[0],
    'func_code',    $int_fuel_func[1],
    'device_data',  $int_fuel_func[2]
);

It's not a form value. Value automatically insert when the page is refreshed.

It's only inserts first value 'device_id', $int_fuel_func[0],. Other two values are not insert into my database. Any one suggest me how to insert these values.

Thanks in advance

Cake version 2.7.5

  • 写回答

3条回答 默认 最新

  • duanhao4909 2017-01-07 10:41
    关注

    My id is not auto Increment it is defined as varchar. Time is not include there also. I got my answer. I use it and it works.

    $this->Fuel->set(
        array(
            'device_id'   => $int_fuel_value[0],
            'func_code'   => $int_fuel_value[1],
            'device_data' => $int_fuel_value[2]
        )
    );
    $this->Fuel->save();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?