0
Hello, the code to update a record to another table does not work.
I need to update the table vendas
when saving a record from the table lancamentos
.
on the table lancamentos
there is the column vendas_id
, which contains the id related to an invoiced sale.
When I edit the release, I need the idLancamentos
column lancamentos_id
on the table vendas
.
The controller has the following function:
if ($this->financeiro_model->edit('lancamentos',$data,'idLancamentos',$this->input->post('id')) == TRUE) {
//$estornado = 0;
$venda = $this->input->post('venda_id');
$lancamento = $this->input->post('idLancamentos');
$sql = "UPDATE vendas set lancamentos_id = lancamentos_id = ? WHERE idVendas = ?";
$this->db->query($sql, array($lancamento, $venda));
$this->atualizaSaldoEditar();
echo json_encode(array('result'=> true));
$this->session->set_flashdata('success','lançamento editado com sucesso!');
redirect($urlAtual);
} else {
$this->session->set_flashdata('error','Ocorreu um erro ao tentar editar lançamento!');
echo json_encode(array('result'=> false));
redirect($urlAtual);
}
To be more precise, I believe the problem is in the Code below:
$venda = $this->input->post('venda_id');
$lancamento = $this->input->post('idLancamentos');
$sql = "UPDATE vendas set lancamentos_id = lancamentos_id = ? WHERE idVendas = ?";
$this->db->query($sql, array($lancamento, $venda));
Dude, for starters, it doesn’t make any less sense that you’re the one
vendas_id
on the tablelancamentos
and alancamentos_id
on the tablevendas
. Second, it’s a mess of your column names, there are times you use Camel Case, ten hours you don’t...it’s not clear what’s real. Third, which error you receive, give some message or simply don’t update?– Kenny Rafael
Hey, buddy, don’t take Camelcase wrong, 'cause I put in a quick one of what I need. The sense of having the sale in launches is in... When I register a sale, it does not yet belong to the launch, but when I FATURO this sale, There is included as Revenue in the launch, being that the value of the billed balance is aggregated to an account. If launched = Revenue = Positive balance | If launched = Expense = Negative balance
– Wagner Fillio
So, in case there’s a need to disrupt this launch. Paid to Estornado, I can assign this same status to the registration of the sale in question. And for that I need to assign the release ID to the sales table. E receives no error. I get the message that the record was saved successfully and the status in the table
lancamentos
is being amended, however the update in the sales table is not performed.– Wagner Fillio
Post the content of this method:
$this->atualizaSaldoEditar();
– Kenny Rafael