Codeigniter delete query from Database

Today, We want to share with you Codeigniter delete query from Database.In this post we will show you deletes query in codeigniter with where condition, hear for Codeigniter Active Record: Insert, Select, Update, Deletes we will give you demo and example for implement.In this post, we will learn about Delete Query In Codeigniter Example Tutorial with an example.

Codeigniter delete query from Database

There are the Following The simple About where condition in codeigniter Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to delete data from database in codeigniter using ajax, so the select query in codeigniter controller is used for this example is following below.

delete query in codeigniter
delete query in codeigniter

There are the Following the List of deletes/remove record in codeigniter methods:

  • $this->db->delete()
  • $this->db->empty_table()
  • $this->db->truncate()
  • Delete With Join

Using $this->db->delete()

$this->db->delete('tbl_patient', array('doctor_id' => $doctor_id)); 
//DELETE FROM tbl_patient WHERE doctor_id = $doctor_id
$this->db->where('doctor_id', $doctor_id);
//DELETE FROM tbl_patient WHERE doctor_id = $doctor_id

simple pass An array of Dataabse table names can be argument passed into delete() function if you would like to simple database table to deletes/remove data from multiple table.deletes query in codeigniter with where condition

$tables = array('doctor', 'staff', 'category');
$this->db->where('doctor_id', $doctor_id);

Using $this->db->empty_table()

// DELETES FROM tbl_patient

Using $this->db->truncate()

// TRUNCATE table tbl_patient;

Delete With Join

$this->db->join("staff", "doctor.t1_doctor_id = staff.t2_doctor_id");
$this->db->where("staff.t2_doctor_id", $doctor_id);
Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Codeigniters CRUD Active Record: Insert, Select, Update, Deletes Example.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment