Welcome Guest, Not a member yet? Register   Sign In
Problem: Can't call a model function in my library!
#1

[eluser]Jason van der Zeeuw[/eluser]
Hey all,

Here is my problem code:

Code:
var $CI; //Contains an instance of the library

    public function __construct() {
        $this->CI = & get_instance();
        $this->CI->load->model('mymodel');        
    }

    function test()
    {        
        return $this->mymodel->testmethod());
    }

I get 2 errors:

Message: Undefined property: My_library::$mymodel (so he doesn't knows 'mymodel')
&
Fatal error: Call to a member function testmethod() on a non-object
#2

[eluser]vrencianz[/eluser]
Try

Code:
$this->CI->mymodel->testmethod();

instead
#3

[eluser]InsiteFX[/eluser]
Code:
private $CI; //Contains an instance of the library

    public function __construct()
    {
        $this->CI =& get_instance();
        $this->CI->load->model('mymodel');        
    }

    function test()
    {        
        return $this->CI->mymodel->testmethod());
    }
#4

[eluser]Jason van der Zeeuw[/eluser]
OMG thank you so much,
I feel so stupid Tongue

this is the first time I work with CI so thank you guys!




Theme © iAndrew 2016 - Forum software by © MyBB