private function atualizaNivelEstoque(estoqueModel $estoque) { try { $this->db->clear(); $this->db->setTabela('nivel_estoque'); $this->db->setCondicao("id_estoque = ? AND localizacao_estoque = ?"); $this->db->setParameter(1, $estoque->getId()); $this->db->setParameter(2, $estoque->getLotes()[0]->getLocalizacao()[0]->getLocalizacao()); if (!$this->db->select()) { $data = array('id_estoque' => $estoque->getId(), 'localizacao_estoque' => $estoque->getLotes()[0]->getLocalizacao()[0]->getLocalizacao()); $this->db->clear(); $this->db->setTabela('nivel_estoque'); $this->db->insert($data); } } catch (dbException $e) { $this->db->query('ROLLBACK'); return $e->getMessageError(); } }