尝试使用cakephp 2.0保存表单数组数据

时间:2015-06-04 19:01:22

标签: arrays save cakephp-2.0

Array
(
    [submit] => Save
    [PeachesProduct] => Array
        (
            [pro_category_id] => 1
            [pro_title] => qeqqe
            [pro_desc] => add
            [pro_quan] => 313
            [pro_price] => 12
            [pro_ship_days] => 21
            [pro_status] => A
        )

    [PeachesProductDetail] => Array
        (
            [size] => Array
                (
                    [0] => 12
                    [1] => 12
                    [2] => 13
                    [3] => 12
                )

            [price] => Array
                (
                    [0] => 21323
                    [1] => 21323
                    [2] => 21323
                    [3] => 313
                )

        )

)

1 个答案:

答案 0 :(得分:0)

if($this->request->data) {
    if(this->PeachesProduct->saveAll($this->request->data, array('deep' => true))) {
        // saved do somthing
    }
}