Delete Query in PHP Codeigniter Framework

In this Codeigniter delete query tutorial – we would love to share with you how to delete a single or multiple records into database.

In this codeigniter tutorial you will learn how to empty and truncate database tables using codeigniter empty or truncate() method.

Codeigniter Delete Query


  • delete()
  • empty_table()
  • truncate()

delete() method

The Codeigniter Delete function is used to delete the one or more row data from database table.


$this->db->delete('users', array('id' => $id)); 

Produce :

//DELETE FROM users WHERE id = $id

empty_table () Method


// DELETE FROM users

truncate() method

The truncate() method of codeigniter is used to remove all records from a database table. It performs the same function as a DELETE statement without a WHERE clause.


// TRUNCATE table users;

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *