Codeigniter Database Insert Failure
You can use
if($this->db->insert('Faviroute_Addresses', $address_data)){ // Code here after successful insert return true; // to the controller}
Or you can use
$this->db->insert('Faviroute_Addresses', $address_data);if($this->db->affected_rows() > 0){ // Code here after successful insert return true; // to the controller}
Personally I'd avoid using the
$this->db->affected_rows()
method for an insert. SQLServer doesn't return a value for an insert, so taking the return value from
$this->db->insert(...)
would be more reliable. I'd reserve affected_rows for checking "UPDATE"s :)
UPDATE:
The same thing applies for
$this->db->delete()
The affected_rows() function doesn't work in SQL Server on a delete...