CodeIgniter Forums
problem with model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: problem with model (/thread-15328.html)



problem with model - El Forum - 02-01-2009

[eluser]solquagerius[/eluser]
Hello,

i have a little problem with loading a model... i've just began to use codeigniter and i don't know where the problem comes from.
In my controller, i load a model in the constructor, and when the index function call my view page, nothing appears in the web page (nothing in code source). It works normally when i remove the loading of the model...

Thank you.


problem with model - El Forum - 02-01-2009

[eluser]Pascal Kriete[/eluser]
Hi solquagerius,

There isn't a known problem that fits your description, so this is going to be really hard to troubleshoot without either an error message or a snippet of the offending code.

You should definitely have your development environment set up to show all errors. That means error_reporting at E_ALL and display_errors on:
Code:
// In your index.php - remove before you deploy
error_reporting(E_ALL);
@ini_set('display_errors', 1);

It's probably something silly, like a syntax error (happens all the time), but give us something to work with and we'll help you out.

Welcome to Codeigniter.


problem with model - El Forum - 02-01-2009

[eluser]solquagerius[/eluser]
here is my code :

controller file : connexion.php
Code:
class Connexion extends Controller {
        
        function Connexion()
        {
            parent::Controller();
            $this->load->model('Connexion_model','',TRUE);
        }
        
        function index()
        {
            $this->load->view("connexion_view");
        }
      }

model file : connexion_model.php
Code:
class Connexion_model extends Model() {
        
        function Connexion_model()
        {
            parent::Model();
        }
        
        function get_something()
        {
            $query = $this->db->get('user', 10);
            return $query->result();
        }
    }

When i remove the line "$this->load->model..." the index funtion works, otherwise it's not called.


problem with model - El Forum - 02-01-2009

[eluser]garymardell[/eluser]
Code:
$this->load->model('Connexion_model','',TRUE);

What is the 3rd parameter meant to do? I couldn't see any reference to it.
http://ellislab.com/codeigniter/user-guide/general/models.html#loading


problem with model - El Forum - 02-01-2009

[eluser]solquagerius[/eluser]
It is a parameter used to connect to the database (chapter Connecting to the database in the user guide). I tried without parameters but still doesn't work. Maybe it is a problem in my config files (but i didn't change anything except the default_route and enabling database parameters)