Today, We want to share with you Update Query In Codeigniter Example Tutorial.In this post we will show you insert query in codeigniter, hear for select query in codeigniter we will give you demo and example for implement.In this post, we will learn about Select Query In Codeigniter Example Tutorial with an example.
Update Query In Codeigniter Example Tutorial
There are the Following The simple About Codeigniter Active Record: Insert, Select, Update, Delete Full Information With Example and source code.
As I will cover this Post with live Working example to develop delete query in codeigniter, so the join query in codeigniter is used for this example is following below.
PHP Based CodeIgniter Freamworks Like ‘UPDATE’ query statement will run/execute using following methods. They are

In this Example, we will all about how to Update records. I will use docators table to update all the Databse records.
- $this->db->update()
- $this->db->update_string()
- $this->db->update_batch()
Codeigniter (CRUD) Select Insert Update Delete Query
- Update Query In Codeigniter
- Select Query In Codeigniter
- Insert Query In Codeigniter
- Delete Query In Codeigniter
using $this->db->update()
$data = array( 'name' = > $_POST['name'] , 'teamname'= > $_POST['teamname'], 'rate' = > $_POST['rate'] ); $this->db->where('id', $_POST['id']); $this->db->update('tbl_docator', $data);
using $this->db->update_string()
Imp Note: All the Values are automatically restricted escaped, producing safer statements.
$data = array( 'teamname'= >$_POST['teamname'] ); $where = "status = 'docator'"; $str = $this->db->update_string('tbl_docator', $data, $where);
using $this->db->update_batch()
$data = array( array( 'name' = > 'name1' , 'teamname'= > 'teamname1', 'rate' = > 'rate1' ), array( 'name' = > 'name2' , 'teamname'= > 'teamname2', 'rate' = > 'rate2' ) ); $this->db->update_batch('tbl_docator', $data);
Update record CodeIgniter framework PHP
CodeIgniter\application\controllers\Member.php
load->database(); $this->load->model('Member_model'); } public function dispdata() { $result['data']=$this->Hello_model->members_list(); $this->load->view('members_list',$result); } public function updatedata() { $id=$this->input->get('id'); $result['data']=$this->Member_model->displayrecordsById($id); $this->load->view('update_records',$result); if($this->input->post('update')) { $username=$this->input->post('username'); $sirname=$this->input->post('sirname'); $email=$this->input->post('email'); $this->Member_model->update_records($username,$sirname,$email,$id); echo "Date updated successfully !”; } } } ?>
CodeIgniter\application\models\Member_model.php
db->query("select * from crud"); return $query->result(); } function displayrecordsById($id) { $query=$this->db->query("select * from form where id='".$id.”’”); return $query->result(); } function update_records($username,$sirname,$email,$id) { $query=$this->db->query("update form SET username='$username',sirname='$sirname',email='$email' where id='$id’”); } }
CodeIgniter\application\views\members_list.php
Delete records - www.pakainfo.com
Sr No | Member First_name | Member Last_name | Member Email Id | Update | ".$i." | "; echo "".$member->username." | "; echo "".$member->sirname." | "; echo "".$member->email." | "; echo "id."'>Update | "; echo ""; $i++; } ?>
---|
CodeIgniter\application\views\update_records.php
Update Member Data
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 codeigniter CRUD query.
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.