-1
Good morning guys, someone would tell me the best way to treat the following mistake:
The following error occurs when, for example, I have a client in a BD table and in another table I have a budget referencing this client, when I try to exclude the client it presents this error, what is correct I really do not want to delete this client to maintain the integrity of the comic book.
What I want is for this error to be presented in a better way for the user, something in the form of a message explaining why it is not possible to delete the client.
I’m using PHP and codeigniter to make this small system.
Edit, codes used by:
Controller:
function deletar($pcod) {
/* Executa a função deletar do modelo passando como parâmetro o id da pessoa */
if ($this->model->deletar($pcod)) {
$this->session->set_flashdata('mensagem', "<div class='alert alert-warning'> Produto deletado com sucesso</div>");
redirect('produtos');
} else {
$this->session->set_flashdata('mensagem', "<div class='alert alert-danger'> Erro ao deletar Produto</div>");
}
}
Model:
function deletar($pcod) {
$this->db->where('pcod', $pcod);
return $this->db->delete('produtos');
}
just to confirm if I understood I would put this code in my modal ? my sql is as follows:
function deletar($pcod) {
 $this->db->where('pcod', $pcod);
 return $this->db->delete('produtos');
 }
– Felipe Miranda De Lima
Post the part of the code where you delete, I will insert in the correct point to perform the test.
– Bruno Rigolon
Post Edited with the code
– Felipe Miranda De Lima
I changed the code, try the test and see if you’ll answer.
– Bruno Rigolon