CodeIgniter - Delete data from multiple table
In delete function you must be provide array of tables:
function delete_data($id){ $this->db->where('pemohon.id_pemohon=user.id_user'); $this->db->where('pemohon.id_pemohon=peserta.id_peserta'); $this->db->where('pemohon.id_pemohon',$id); $this->db->delete(array('pemohon','user','peserta'));}
If it not worked, execute with query function ($id escaped):
function delete_data($id){ $sql = "DELETE user,pemohon,peserta FROM user,pemohon,peserta WHERE user.id_user=pemohon.id_pemohon AND pemohon.id_pemohon=peserta.id_peserta AND pemohon.id_pemohon= ?"; $this->db->query($sql, array($id));}
And without escaping $id:
function delete_data($id){ $this->db->query("DELETE user,pemohon,peserta FROM user,pemohon,peserta WHERE user.id_user=pemohon.id_pemohon AND pemohon.id_pemohon=peserta.id_peserta AND pemohon.id_pemohon= $id";}
you can try this process
function delete_data($id){ $this->db->delete('user', array('id_user' => $id)); $this->db->delete('pemohon', array('id_pemohon' => $id)); $this->db->delete('peserta', array('id_peserta' => $id));}
You can save table name within an array and pass that array as parameter in delete(). As you can read full example : https://tutorialpace.com/CodeIgniter-Tutorials/CodeIgniter-Database-Delete