[eluser]Emass[/eluser]
Hello.
First, I hope I posted this in the right forum. If not I hope a moderator would move this where it belongs.
I'm facing a problem with loading the models. I think it is because I'm including classes by including them instead of CI's way of loading them through MY_classes. I try to do it this way because I think this way is much more organized. Working perfect except for loading models. Let me just show you an example. This code is inside the backcontroller, which is extending the controller which defines the pages as it's supposed to in CI. In this class I'm trying to load a model like this.
$this->load->model('login_model');
$this->login_model->updateUser($this->sleutel, $this->getLogin(), $this->getTimestmp());
The model looks like this:
<?php
class Login_model extends Model {
function Login_model() {
parent::Model();
}
function updateUser($sleutel, $login, $timestmp) {
$q = $this->db->query('SELECT * FROM `activity` WHERE sleutel = \'' . $sleutel . '\' LIMIT 1');
if($q->num_rows() > 0) {
//update
//$q = $this->db->query('UPDATE `activity` SET `login` = \'' . $login . '\', ');
} else {
//insert
}
var_dump('test');
}
}
?>
In this example I get the following fatal error:
Fatal error: Call to a member function test() on a non-object
It seems it's just not loading the model, even though I defined it in the backcontroller. So I thought I'd auto load the 'login_model' model from the autoload.php to see either it loads then, and with success, except I get the var_dump('test') twice, and I don't want to run my queries twice. Also when I take the $this->load->model('login_model'); out, it will still load it twice.
Anyone has any idea?