Welcome Guest, Not a member yet? Register   Sign In
problem with model
#1

[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.
#2

[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.
#3

[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.
#4

[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-gui...ml#loading
#5

[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)




Theme © iAndrew 2016 - Forum software by © MyBB