Posted inTechnology / Codeigniter / Mysql / Mysqli / php / Programming

Update Query In Codeigniter Example Tutorial

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

Update Query In Codeigniter Example Tutorial
Update Query In Codeigniter Example Tutorial

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

  1. Update Query In Codeigniter
  2. Select Query In Codeigniter
  3. Insert Query In Codeigniter
  4. 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

 

";
  echo "";
  echo "";
  echo "";
  echo "";
  echo "";
  echo "";
  $i++;
  }
   ?>
Sr No Member First_name Member Last_name Member Email Id Update
".$i."".$member->username."".$member->sirname."".$member->email."id."'>Update

CodeIgniter\application\views\update_records.php




Update Member Data

 

 
	
Enter Your Name
Enter Your Email
Enter Your Mobile
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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype