codeigniter update query example
Example 1: 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;
}
Example 2: codeigniter select for update
$table = "my_table";
$id = 1;
$update = ["status"=>"working"];
$query = $this->db->select()
->from($table)
->where('id', $id)
->get_compiled_select();
$data = $this->db->query("$query FOR UPDATE")->row_array();
$this->db->where('id', $data['id'])->update($table,$update);