Today, We want to share with you delete Query In Codeigniter Example Tutorial.In this post we will show you insert query in codeigniter, hear for codeigniter join query we will give you demo and example for implement.In this post, we will learn about Join Query In Codeigniter with an example.
delete Query In Codeigniter Example Tutorial
There are the Following The simple About delete query in codeigniter Full Information With Example and source code.
As I will cover this Post with live Working example to develop join query in codeigniter, so the join in codeigniter is used for this example is following below.
Codeigniter delete database record
codeigniter Delete method is used to remove/delete the one or more records data from MySQL database table. If We need to delete all the MySQL data from a Databse table, We can simple use the truncate() function, or onther methods like as a empty_table().
- $this->db->delete()
- $this->db->empty_table()
- $this->db->truncate()
- Delete With Join
$this->db->delete()
$this->db->delete('tbl_client', array('member_id' => $member_id)); //DELETE FROM tbl_client WHERE member_id = $member_id
$this->db->where('member_id', $member_id); $this->db->delete('tbl_client'); //DELETE FROM tbl_client WHERE member_id = $member_id
simple pass An array of Dataabse table names can be argument passed into delete() function if you would like to simple database table to delete data from multiple table.
$member_id=5; $tables = array('member', 'team', 'category'); $this->db->where('member_id', $member_id); $this->db->delete($tables);
$this->db->empty_table()
$this->db->empty_table('tbl_client'); // DELETE FROM tbl_client
$this->db->truncate()
$this->db->from('tbl_client'); $this->db->truncate(); (OR) $this->db->truncate('tbl_client'); // TRUNCATE table tbl_client;
Delete With Join
$this->db->from("member"); $this->db->join("team", "member.t1_member_id = team.t2_member_id"); $this->db->where("team.t2_member_id", $member_id); $this->db->delete("member");
Example 1: Codeigniter delete database record
Controller
load->database(); $this->load->helper('url'); $this->load->model('Pakainfo_Model'); } public function savedata() { $this->load->view('registration'); if($this->input->post('save')) { $n=$this->input->post('name'); $e=$this->input->post('email'); $m=$this->input->post('phone'); $this->Pakainfo_Model->saverecords($n,$e,$m); redirect("Pakainfo/dispdata"); } } public function dispdata() { $result['data']=$this->Pakainfo_Model->displayrecords(); $this->load->view('display_records',$result); } public function deletedata() { $id=$this->input->get('id'); $this->Pakainfo_Model->deleterecords($id); redirect("Pakainfo/dispdata"); } } ?>
View
Display Records - www.pakainfo.com
Sr No | client Name | client Email | client Phone | client Delete | ".$i." | "; echo "".$client->name." | "; echo "".$client->email." | "; echo "".$client->phone." | "; echo "Delete | "; echo ""; $i++; } ?>
---|
Model
db->query($query); } function displayrecords() { $query=$this->db->query("select * from clients"); return $query->result(); } function deleterecords($id) { $this->db->query("delete from clients where client_id='".$id."'"); } } ?>
Codeigniter (CRUD) Select Insert Update Delete Query
- Update Query In Codeigniter
- Select Query In Codeigniter
- Insert Query In Codeigniter
- Delete Query In Codeigniter
Web Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about select query in codeigniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.