How to delete row from table in codeigniter?

Member

by ryleigh , in category: PHP Frameworks , 4 months ago

How to delete row from table in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lew , 4 months ago

@ryleigh 

To delete a row from a table in CodeIgniter, you can use the following code:

1
2
$this->db->where('id', $id);
$this->db->delete('tablename');


In the above code, replace 'id' with the column name by which you want to identify the row you want to delete, and 'tablename' with the name of the table from which you want to delete the row.


You can then call this code in your controller or model to delete the row from the table.


Make sure you have set up the database configuration correctly in CodeIgniter and loaded the database library before using the above code.