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.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

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.

Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel Increment and Decrement Example
  2.   Laravel Send Email Attachment Tutorial With Example
  3.   Remove specific value from php array
  4.   Increment Decrement with Laravel 6 Example
  5.   codeigniter print last query - PHP Examples
  6.   PHP Set custom headers using cURL Example
  7.   How to Create CAPTCHA image verification using PHP and jQuery
  8.   Remove empty values from array in PHP
  9.   DataTables Pagination Server-side Processing using PHP and MySQL
  10.   PHP Laravel 7 Inner Join Query Example (join query in laravel)