Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Call to a member function get() on a non-object in
#11

[eluser]viktors[/eluser]
I think what class CI_Model can't load datebase object.
#12

[eluser]toopay[/eluser]
Can you be more details, because your code suppose to works. Your CI version, PHP version, OS...
#13

[eluser]viktors[/eluser]
OS: Windows 7(32);
Server: XAMP 1.7;
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
mysql: 5.0.7-dev - 091210 - $Revision: 304625 $
CI version 2.0.2
#14

[eluser]toopay[/eluser]
Sounds weird, it should works.
Let's test that, put this in your test.php (test model class)
Code:
// Just to see if the db object is available
    function __construct()
    {
        parent::__construct();
        if( ! isset($this->db)) $this->load->database();
        var_dump($this->db);
        exit;
    }
#15

[eluser]viktors[/eluser]
Fatal error: Call to a member function database() on a non-object in C:\xampp\htdocs\be\application\models\test.php on line 7
#16

[eluser]CodeIgniteMe[/eluser]
It worked very fine for me. Try re-installing your CI Installation.
#17

[eluser]toopay[/eluser]
@viktors, what happen if you do this
Code:
<?php
class Test extends CI_Model {

    function __get($key)
    {
        $CI =& get_instance();
        return $CI->$key;
    }

    function test1()
    {    
        $q=$this->db->get('article_content');
        return  $q->num_rows();
    }
}
#18

[eluser]viktors[/eluser]
Strange CI reinstalled and it worked. Thank you all!
#19

[eluser]viktors[/eluser]
[quote author="toopay" date="1309533104"]@viktors, what happen if you do this
Code:
<?php
class Test extends CI_Model {

    function __get($key)
    {
        $CI =& get_instance();
        return $CI->$key;
    }

    function test1()
    {    
        $q=$this->db->get('article_content');
        return  $q->num_rows();
    }
}
[/quote]

Fatal error: Call to a member function get() on a non-object in model/test.php

I had to change yesterday character set the entire project, may this was the cause
#20

[eluser]toopay[/eluser]
[quote author="viktors" date="1309533250"]Strange CI reinstalled and it worked. Thank you all![/quote]

Since its works, i suspect your last issue is related with cache stuff mechanism in your browser. The code i gave is for your previous CI instalation (which not works), just add a magic function __get, so that $this->load->database() could work (but not neccessary anymore, since it can load the CI object already right now).




Theme © iAndrew 2016 - Forum software by © MyBB