update query in CI 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 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);