I'm studying Zend Framework 2 and am needing a hand to do an update on two tables that are related. Come on.
I have the table entries with the fields:
id_entrada id_notafiscal
and in the fiscal_notes table the fields:
id_notafiscal cod_notafiscal
I have summarized the number of fields to facilitate.
I need to update the invoice table and even get the query:
UPDATE notafiscal en
INNER JOIN entrada e
ON e.id_notafiscal = en.id_notafiscal
and id_entrada='2014-02-24'
SET cod_notafiscal=1
How to do this using Zend 2?
To facilitate a little more I will post the code that I use to make a select
between multiple tables.
public function find($id)
{
$id = (int)$id;
$sql= $this->tableGateway->select(function (Select $select) use ($id) {
$select->join('enotafiscal','entrada.id_notafiscal=enotafiscal.id_notafiscal','cod_notafiscal','left');
$select->join('fornecedor','entrada.id_fornec=fornecedor.id_fornec','desc_forn','left');
$select->join('produtos','entrada.id_produto=produtos.id_produto','desc_produto','left');
$select->where(array ('id_entrada' => $id));
});
$row =$sql->current();
if (!$row){
throw new \Exception("Não foi encontrado entrada com o id = {$id}");
}
return $row;
}
Is it possible to do this using the Zend TableGateway class?