How to delete row from table in codeigniter?

Member

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

How to delete row from table in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lew , 9 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.

Related Threads:

How to delete single row in pivot table with laravel?
How to delete a row in database using codeigniter?
How to delete specific column in a row in codeigniter?
How to add a table row with p5.js?
How to duplicate table row based on column value in teradata?
How to resolve the "cannot delete or update a parent row" error in mysql?