13
Apr
Learn how to empty or truncate table using codeigniter active record
If you want to empty or truncate a mysql table using codeigniter active record, use the following code.
To empty
$this->db->empty_table();
This will generate a delete SQL string and runs the query.
// DELETE FROM mytable
To truncate
$this->db->from('mytable'); $this->db->truncate(); // or $this->db->truncate('mytable');
This will generate a truncate SQL string and runs the query.
// TRUNCATE mytable