if ($this->db->affected_rows() > 0) { return TRUE; } else { return FALSE; }
or
if ($this->db->affected_rows() > 0) return TRUE; else return FALSE;
or
return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
also(much better)
return ($this->db->affected_rows() > 0);
A better solution I’ve found is to manage the difference between an ERROR and 0 affected rows. 0 affected rows is not necessarily a bad thing, but an error is something you do want to know about:
if ($this->db->_error_message()) { return FALSE; // Or do whatever you gotta do here to raise an error } else { return $this->db->affected_rows(); }
Now your function can differentiate…
if ($result === FALSE) { $this->errors[] = 'ERROR: Did not update, some error occurred.'; } else if ($result == 0) { $this->oks[] = 'No error, but no rows were updated.'; } else { $this->oks[] = 'Updated the rows.'; }
Just some quick hacking there – you should obviously make the code far more verbose if you have other people using it.
The point is, consider using _error_message to differentiate between 0 updated rows and a real problem.
Contact Controller [crayon-67a5ae656b0b7944487654/] Contact_form.php - view [crayon-67a5ae656b0c3867770218/] Contact_model [crayon-67a5ae656b0c8374061358/] Captcha Helper [crayon-67a5ae656b0cf869854359/] Notifications_model [crayon-67a5ae656b0d6700862690/] Database…
[crayon-67a5ae656b6b1125348967/] [crayon-67a5ae656b6ba909367333/]
[crayon-67a5ae656b9d8092990030/] The first parameter specifies the type of string, the second parameter specifies the length.…
Create Controller [crayon-67a5ae656bc50576706918/] 2. Create View File [crayon-67a5ae656bc58527344809/]
[crayon-67a5ae656c9fb105664483/] [crayon-67a5ae656ca05087359056/]
All of the native error messages are located in the following language file: system/language/english/form_validation_lang.php To set…