CodeIgniter – Update Query

CodeIgniter 'UPDATE' query will execute using following functions. They are

$this->db->update()


$data = array( 
    'name'	= >  $_POST['name'] , 
    'groupname'= >  $_POST['groupname'], 
    'age'	= >  $_POST['age']
);
$this->db->where('id', $_POST['id']);
$this->db->update('tbl_user', $data);

$this->db->update_string()

Note: Values are automatically escaped, producing safer queries.

$data = array(
    'groupname'= >$_POST['groupname']
);
$where = "status = 'user'"; 
$str = $this->db->update_string('tbl_user', $data, $where);

$this->db->update_batch()


$data = array(
    array(
        'name'	= >  'name1' , 
        'groupname'= >  'groupname1', 
        'age'	= >  'age1'
    ),
    array(
        'name'	= >  'name2' , 
        'groupname'= >  'groupname2', 
        'age'	= >  'age2'
    )
);
$this->db->update_batch('tbl_user', $data);