3 Replies - 854 Views - Last Post: 10 July 2012 - 02:08 AM Rate Topic: -----

#1 Alhazred  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 174
  • Joined: 25-July 07

[CodeIgniter] How do I get error messages from models with mistakes?

Posted 08 July 2012 - 01:52 AM

I'm at my first experience with CodeIgniter, I'm using the version 2.1.2

From a controller I call a model, the call is correct because if I put a wrong name for the model I get an 404 error because the model is not found.

As the code arrives to the model's call the flow stops and I have a blank page.
I think there must be an error inside the model, but I donì't get any error message.

I've tried to put in several points an echo as debug and then an exit(), but the echo isn't shown.

How can I display php errors occurring inside models?

This post has been edited by Alhazred: 08 July 2012 - 01:54 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [CodeIgniter] How do I get error messages from models with mistakes?

#2 Alhazred  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 174
  • Joined: 25-July 07

Re: [CodeIgniter] How do I get error messages from models with mistakes?

Posted 08 July 2012 - 03:24 AM

I think the problem is somewhere else, I've tried to comment all the code inside the model leaving only the constructor, the controllers stops at the model call.
here is the code I'm running now to try.

Controller
class Authentication extends CI_Controller 
{
 /**
  * Funzione di login
  * @return boolean true in caso di successo, false altrimenti
  */
 public function login()
 {
  //form validation
  $this->load->library('form_validation');
  $this->form_validation->set_rules('username', 'lang:form_username', 'required|alpha_dash');
  $this->form_validation->set_rules('password', 'lang:form_password', 'required');
  
  //caricamento file messaggi autenticazione
  $this->lang->load('authentication_messages');

  if ($this->form_validation->run() == FALSE) //field validation failed
  {
   $data['message'] = lang('auth_login_validation_error');
   $this->load->view('authentication/login_form',$data);
  }
  else //fields ok
  {
   $username = $this->input->post('username',TRUE);
   $password = $this->input->post('password',TRUE);
   
   //load model, it is inside a subfolder, models/authentication/authentication.php
   //THE EXECUTION STOPS AT THIS LINE IF I REMOVE IT THE CONTROLLER GOES ON
   $this->load->model('authentication/Authentication');

   //$this->Authentication->init($username,$password); //inizializza l'oggetto
   
   $result = FALSE; // was $this->Autentication->login(); changed to debug
   if ( ! $result) //login failed
   {
    $data = array(); //reset dell'array $data
    $data['message'] = lang('auth_login_error');
    $this->load->view('authentication/login_form',$data);
   }
   else //login successful
   {
    $this->load->view('authentication/login_success');
   }
  }
 }
}  



Model
class Authentication extends CI_Model
{
  function __construct()
  {
    parent::__construct();
  }
}



Into the browser's address bar I see the url to the controller function login()
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: [CodeIgniter] How do I get error messages from models with mistakes?

Posted 08 July 2012 - 03:40 AM

I don't use CI, I use CakePHP, so I'm not sure how helpful this will be, but perhaps. The framework may be setup to hide these sorts of errors from the end user. There may also be a DEBUG-type configuration variable that dictates whether these low-level errors print to the screen (I know this is the case with CakePHP). You can try checking any logs CI might generate, or the general PHP log file (if you've set it up) as well. I'm sure it's being logged somewhere.

Just a couple of ideas.
Was This Post Helpful? 1
  • +
  • -

#4 menukadevinda  Icon User is offline

  • D.I.C Regular

Reputation: -7
  • View blog
  • Posts: 470
  • Joined: 14-April 11

Re: [CodeIgniter] How do I get error messages from models with mistakes?

Posted 10 July 2012 - 02:08 AM

Have you put another folder name authentication to the model fo lder and placed Authentication model class file in the project?

I think in codeigniter, you better put Authentication file in model folder not in authentication folder.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1