Welcome Guest, Not a member yet? Register   Sign In
Check database error in insert and update
#1

[eluser]Unknown[/eluser]
I would like to ask on how will I catch database error in code igniter,I mean if there are any built-in function for these.i just want to change these ff coding because i think its not working.
Code:
//my model
        public function add_reg($uname,$fname,$lname,$disp_name,$email,$pwd)
{
  $err = 0;

  $data = array(
   'uname' => $uname,
   'fname' => $fname,
   'lname' => $lname,
   'disp_name' => $disp_name,
   'email' => $email,
   'pwd' => $pwd
   );
  
  try {
   $this->db->insert('user',$data);
  } catch (Validation_Exception $e) {
   $err = 1;
  }
  return $err;
}

Code:
//controller
     if ($this->form_validation->run() == TRUE)
{
         $add_reg = $this->Reg_model->add_reg(
         $_POST['uname'],
  $_POST['fname'],
  $_POST['lname'],
  $_POST['disp_name'],
  $_POST['email'],
  $_POST['pwd']);

  if($add_reg == 0){
     echo 'Your are successfully registered.!';
                }
        }
please help me.:down:
#2

[eluser]DarkManX[/eluser]
ci puts out error by itself.
#3

[eluser]Unknown[/eluser]
For even better error reporting Dan Horrigan ported a great error reporting script to CI which you can find on Github. This must never be switched on in a live-site environment but is a huge help during production and has probably saved me hours already.





Theme © iAndrew 2016 - Forum software by © MyBB