Delete Query in PHP Codeigniter Framework
In this Codeigniter tutorial, we will show you how to delete one or more records from a database.
You will learn how to use Codeigniter to delete a single or multiple records from the database. We will also teach you how to empty or truncate database tables using the 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;

