codeigniter in get query code example

Example 1: update in codeigniter query

$data = array(
        'title' => $title,
        'name' => $name,
        'date' => $date
);

$this->db->where('id', $id);
$this->db->update('mytable', $data);
// Produces:
//
//      UPDATE mytable
//      SET title = '{$title}', name = '{$name}', date = '{$date}'
//      WHERE id = $id

Example 2: codeigniter raw query

$sql="Select * from my_table where 1";    
    $query = $this->db->query($SQL);
    return $query->result_array();

Example 3: codeigniter 3 update

$data = array(
        'title' => $title,
        'name' => $name,
        'date' => $date
);

$this->db->where('id', $id);
$this->db->update('mytable', $data);

Tags:

Misc Example