codeigniter 4 update code example
Example 1: codeigniter update
$data = [
'title' => $title,
'name' => $name,
'date' => $date
];
$builder->where('id', $id);
$builder->update($data);
// Produces:
//
// UPDATE mytable
// SET title = '{$title}', name = '{$name}', date = '{$date}'
// WHERE id = $id
Example 2: codeigniter 3 update
$data = array(
'title' => $title,
'name' => $name,
'date' => $date
);
$this->db->where('id', $id);
$this->db->update('mytable', $data);
Example 3: codeigniter 4 query builder select
$builder->select('title, content, date');
$query = $builder->get();
// Executes: SELECT title, content, date FROM mytable