CodeIgniter Delete Query

In this tutorial you will learn about the CodeIgniter Delete Query and its application with practical example.

In CodeIgniter, delete() method is used to delete an existing record from database table. In order to generate delete statement, delete() method is used in following ways –

Syntax:-

Here,

$table(mixed):- The table(s) to delete from. String or array

$where(mixed):- The where clause

$limit(mixed):- The limit clause

$reset_data(bool):- TRUE to reset the query “write” clause

Returns(mixed)

Example:- Let’s say you have a MySQL table named ’employee_master’ with the following fields –
emp_ID, emp_name, emp_email, emp_phone, emp_address, emp_code and emp_dept

Delete Record using $this->db->delete()

This is how you can delete a record from ’employee_master’ table using $this->db->delete().

An array of table names can be passed into delete() if you would like to delete record(s) from multiple tables.

Delete All Records using $this->db->empty_table()

This is how you can delete all records from ’employee_master’ table using $this->db->empty_table().

Delete All Records using $this->db->truncate()

This is how you can delete all records from ’employee_master’ table using $this->db->truncate().

Delete With Join

 

 

 

In this tutorial we have learn about the CodeIgniter Delete Query and its application with practical example. I hope you will like this tutorial.