Pergunta

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.

Foi útil?

Solução

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
                )
        )
)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top