I want to delete data from 3 table,i have table user,pemohon,peserta where all table is connected each other with foreign key.
this query work,I've tried on mysql
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=1
so i convert to CodeIgniter like this
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('pemohon','user','peserta');
}
but this code not work, can you fix my code? Thanks
$this->db->query("Put your query here which you run in mysql")this query workthen Why it does not work?? .Try it with give static idpemohon.id_pemohon=1and also check$idhave value or not?$idthe id not give the value, but when i print$idit give value, i think i just can't Directly insert$idin$this->db->queryis there any other way?$idindelete_datafunction ?? try this : $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."'");`