CodeIgniter Forums
HTTP error 500 when loading model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: HTTP error 500 when loading model (/showthread.php?tid=46008)



HTTP error 500 when loading model - El Forum - 10-14-2011

[eluser]Unknown[/eluser]
Hi there

I am stuck in a problem with Codeigniter where I am getting a http 500 (Internal Server Error) as soon as I am trying to load a model from my controller. When I comment the loading of the model out, the view loads just fine.

Here is what I have got:

My Controller function (controllers > objects.php):
Code:
public function all()
{
  

  // gets all objects and displays them
  // -----------------------------------------------

  // get objects from db
  $this->load->model('objects_model');
  $viewdata['query'] = $this->objects_model->all();

  // load view
  $viewdata['view_content'] = 'objects_all_view';
  $this->load->view('inc/template',$viewdata);
}

My model (models > objects_model.php)
Code:
function all()
  {
  
   // gets all objects
   // -----------------------------------------------
  
   $this->db->select('obj.ID, fv.value');
   $this->db->from('objects obj, fields_values fv, fields_def fd');
   $this->db->where('fv.status = \'active\' AND obj.ID = fv.objects_ID AND fv.fields_def_ID = fd.ID AND fd.name = \'Bezeichnung\'');
   $query = $this->db->get();
  
   return $query;
  
  } // end all()

It does not matter if I insert the two lines for loading the model in the index function or in another function such as all() in this example. As soon as I insert these two lines, I get the 500 error.

The 'database' library is autoloaded.

Thank you for any help or hint!
Aaron