문제

I want to save my array with multiple indexing array values. Demo code

Array
(
    [CodeConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 
                )
        )
    [ObjectAccountConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 2
                )
        )
    [TaxConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 2
                    [IsDirty] => 1
                )

            [1] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 1
                )
        )
)

I want to save this array values direct into table .Table name is audit_trail_details. so please suggest mi proper solution for how to save this data into table.

도움이 되었습니까?

해결책

You need to use saveAssociated and parse your array as the first parameter:-

$this->AuditTrailDetail->saveAssociated($data);

You will also need to make sure $data contains the AuditTrailDetail you are saving the associated data against. For example:-

Array
(
    [AuditTrailDetail] => Array
        (
            [id] => 1
        )
    [CodeConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 
                )
        )
    [ObjectAccountConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 2
                )
        )
    [TaxConfiguration] => Array
        (
            [0] => Array
                (
                    [LineNo] => 2
                    [IsDirty] => 1
                )

            [1] => Array
                (
                    [LineNo] => 1
                    [IsDirty] => 1
                )
        )
)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top