我想删除一个transporteur,我在数据库中有一个属性需要更改为0
添加运营商时会分配此属性,并删除它必须返回零
谢谢你的帮助
模型运输工具
public function delete($email)
{
$this->db->delete('transporteur', array('email' => $email));
}
controlleur transporteur
public function delete()
{
$users = $this->transporteur_model->get_emails();
$this->load->view('admin_delete_tr', array(
'users' => $users
));
}
public function delete_user()
{
sleep(1);
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'required|max_length[40]|valid_email');
if ($this->form_validation->run() == FALSE) {
$message = "<strong>suppression</strong> echoué!";
$this->json_response(FALSE, $message);
} else {
$email = $this->input->post('email');
$this->transporteur_model->delete($email);
$message = "<strong>".$email."</strong> a été supprimé!";
echo json_encode(array(
'isSuccessful' => TRUE,
'message' => $message,
'email' => $email
));
}
}
答案 0 :(得分:0)
您可以在交易中完成。如果您收到任何错误,请告诉我
public function delete($email, id_camion) {
$this->db->trans_start();
$this->db->delete('transporteur', array('email' => $email));
$this->db->where('cid', $id_camion);
$this->db->update('camion', array('etat' => 0));
$this->db->trans_complete();
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
}
else {
$this->db->trans_commit();
}
}