Foreach inside if Cakephp

1

I have a table A that stores an item, and in this table, I have a related table B that can have multiple items added to an item in table A.

Follow if code:

if ($this->ClientePagamento->save($valor_pagar)) {
            $this->Session->setFlash('Valor adicionado com Sucesso');
            $id_valor = $this->ClientePagamento->id;
            foreach($moedas_ativas as $moeda){                    
                $itens_referentes = array(
                    'cliente_pagamento_id' => $id_valor,
                    'valor' => $moeda[key($moeda)]['valor_reais'],                                                
                );
                $this->ClientePagamentoItem->save($itens_referentes);
            }  

In this foreach are the items that should be saved, but the foreach only runs once and ends up saving only the first item, and the array has more than 1 item. Is this a semantic error or something?

    
asked by anonymous 06.07.2015 / 17:10

0 answers