Is it safe to assume in codeigniter query builder class for every successful query it will automatically return true and false if it fails?
If so, does it apply to CRUD? or is it only true when inserting and deleting data? For updating would i have to check affected rows? or will it also return a true result if update was successful?
For example:
controller:
$data = array('username' => $this->input->post('username'),
'password' => password_hash($this->input->post('password'), PASSWORD_BCRYPT),
'date_created' => mdate('%Y-%m-%d', time())
);
$result = $this->account_model->create($data);
if($result == TRUE){
$this->session->set_flashdata('message', 'Registration Successful');
redirect('pages/login');
}else{
$this->session->set_flashdata('message', 'Registration Failed');
redirect('pages/register');
}
model:
public function create($new_user){
$insert = array('username' => $new_user['username'],
'password' => $new_user['password'],
'date_created' => $new_user['date_created']
);
$result = $this->db->insert('user', $insert);
return $result;
}
also, is it bad if i returned the query statement itself? like,
return $this->db->insert('user', $insert);
trueorfalsethe same applies forupdate- its probably up to you how you assess those specifications. - sintakonte