Tutorialsplane

Codeigniter get affected rows insert example


Codeigniter get affected rows insert example : $this->db->affected_rows(); is used to get affected rows in codeigniter.

Codeigniter get affected rows insert example

$data = array(
               'id' => $id,
               'name' => $name,
               'email' => $email,
               'phone' => $phone
            );

$this->db->insert('table_name', $data);
$affected_rows = $this->db->affected_rows();

Will Return no of rows inserted.