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;

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

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 *