Welcome Guest, Not a member yet? Register   Sign In
Undefined property after loading a model
#11

[eluser]BrainCatcher[/eluser]
Thanx for the effort in advance, Here's the full post of the controller (with line 19 commented) and model:

controller login.php
Code:
<?php

class Login extends Controller{
        function  __construct ()  {
        parent::Controller();
    }

    
    function index(){
        $this->load->view('includes/header');
        $this->load->view('login_form');        
        $this->load->view('includes/footer');
        
    }
    
    function inloggen()
    {
        $this->load->model('Authenticate_model');
        $query = $this->Authenticate_model->user_validate();//this is line 19 causing the error
        
        if ($query){
            $data = array(
                    'username' => $this->input->post('username'),
                    'is_logged_in' => true
                
                );
                
                $this->session->set_userdata('$data');
                redirect('site');
        }
        
            else{
                
                $this->index();
            }
    }
    
}



?>

model authenticate_model.php
Code:
class Authenticate_model extends Model {
       function  __construct ()  {
        parent::Model();
    }


    
    function user_validate()
    {
        $this->db->where('fld_username', $this->input->post('username'));
        $this->db->where('fld_password', $this->input->post('password'));
        $query = $this->get('tbl_werknemers');
        
        if ($query->num_rows() == 1){
            
            return true;
        }    
    
    }
}

?>

it looks to me that the model isn't loaded properly, so it can't find the function either...

Thanx for your help
#12

[eluser]BrainCatcher[/eluser]
Still stuck with the same problem. Trying to troubleshoot it, but no succes. I moved the files away from IIS7, and copied them on my apache webserver, changed the base url. And guess what? Another problem..

The page blanks and display's the following error:

Fatal error: Class 'CI_Log' not found in /volume1/web/test/ci172/system/codeigniter/Common.php on line 148

How can I troubleshoot the problem?? Do you have better methods?

I'm not a newbie concerning PHP but not familiar with MVC and OO, my first 2 days with CI and the first tutorial is giving me lots of stress....and headaches

I'm used to procedural scripting within PHP. Some features i'm trying to create for my new project would probably be finish by now if i'd done it the old fashioned way....

With all respect, CodeIgniter and its support is awesome! But right now i'm not getting anywhere..........

Plz Help, it should be something stupid :coolmad:
#13

[eluser]pistolPete[/eluser]
The logging class is not mentioned anywhere near line 148.
Could you try downloading CodeIgniter again and start over with a fresh copy?
Maybe your copy was corrupted somehow.
#14

[eluser]jedd[/eluser]
FWIW, this forum isn't scattered with people having the same problem, so it's probably something specific to your environment there.

Right now I'd probably just dump what I have, and start again with a new copy of the CI core, and pick a different tutorial to be getting on with.

If you have an Apache / Linux web server, I'd stick with developing on that - IIS is the smaller camp for most people around here, and has generally been regarded as a product that does Weird Things (and not just by CI types).
#15

[eluser]BrainCatcher[/eluser]
@jedd and @pistolPete:

I got the picture. I had already started a fresh install, and made the same example as i had before (i wrote it again) and placed the files on my webserver (apache/Linux). Problems solved!! So, i already deinstalled IIS (which was working for me for 2 years without any problems) And installed WAMP on my laptop. At the moment i'm testing and searching for errors... ;-P
#16

[eluser]BrainCatcher[/eluser]
U guys are devoted en motivated to help others! That's the 2nd most important point of using CodeIgniter.

thnx for helping me out this time!
#17

[eluser]CI Coder[/eluser]
[quote author="jedd" date="1256316498"]FWIW, this forum isn't scattered with people having the same problem, so it's probably something specific to your environment there.

Right now I'd probably just dump what I have, and start again with a new copy of the CI core, and pick a different tutorial to be getting on with.

If you have an Apache / Linux web server, I'd stick with developing on that - IIS is the smaller camp for most people around here, and has generally been regarded as a product that does Weird Things (and not just by CI types).[/quote]

I ran into the same problem on Apache / Linux. I am not sure, but I kind of guess why it happens. When I try to load a model from another model I get the error. If, however, I do this:
Code:
$CI =& get_instance();
$CI->load->model('my_model');
$CI->my_model->method('something');
it works just as intended. I am guessing CI doesn't quite like the fact that I name instances of my models differently than their class names. There might be something with the way CI assigns variables to objects. Anyway, CI is still best.
#18

[eluser]jedd[/eluser]
Hi CI Coder and welcome to the CI forums.

Two observations from what you've said here.

First - if you read the Model section of the user guide, you'll see that CI suggests you do this instead:

Code:
->load->model('Your_model');
->Your_model->method('something');

Specifically, upper-case first, rest lower case. Model name (class) should be the same. Filename should be lower case.


Second thing, avoid using the 'my_' prefix as it's confusing with the standard MY_ extension (documented in the Extending Core Classes section of the user guide).
#19

[eluser]CI Coder[/eluser]
"my_model" was just a placeholder for exemplification. In actuality my models are "User_model", "Registration_model" and so on. I haven't inspected it thoroughly because when I ran into this problem I was pressed for time and I just had to have the project done. However, when I saw the error the first thing that came to mind was the way CI assigns variables to the objects and that's how I came up with the work-around.

Anyway, I will be investigating this in more details and I will post my results.

Thanks for the reply.




Theme © iAndrew 2016 - Forum software by © MyBB