Delete rows from multiple tables with CodeIgniter's query builder
03:20 29 May 2017

I want to delete data from 3 tables. I have tables user,pemohon,peserta where all tables are connected to each other via foreign keys.

This query works, 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

I converted 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 does not work. Can you fix my code?

php mysql codeigniter query-builder delete-operator