codeigniter update where query code example

Example 1: update query in codeigniter using where condition

public function update_row(){
		
		$update_rows = array('field-name' => 'field-data',);
		$this->db->where('id', 1 );
		$this->db->update('table-name', $update_rows);	

	}

Example 2: codeigniter update query return value

public function update_row(){
		
		$update_rows = array(
			'name' => 'rincky',
			'address' => 'India',
			'contact' => '98545785',
			'department' => 'IT',

		);
		$this->db->where('id', 1 );
		$result = $this->db->update('user', $update_rows);	
		return $result;
	}

Tags:

Php Example