Delete Query in PHP Codeigniter Framework

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

Contents

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

delete() method

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

syntax

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

Produce :

//DELETE FROM users WHERE id = $id

empty_table () Method

Syntax 

$this->db->empty_table('table_name');
$this->db->empty_table('users'); 
// 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.

Syntax

$this->db->truncate('table_name');
$this->db->truncate('users'); 
// TRUNCATE table users;

AuthorTuts Make

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

One reply to Delete Query in PHP Codeigniter Framework

  1. nice post

Leave a Reply

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