Welcome Guest, Not a member yet? Register   Sign In
problems running ci in php4 - extended classes
#1

[eluser]yabune[/eluser]
Hi,

I had a server problem, and temporarily I'm trying to run my CI site in another server with PHP4.

But I'm getting some problems with extended classes.

I'm getting this error:
Quote:Fatal error: Call to a member function on a non-object in /home/.sites/148/site6/web/cresc2/application/libraries/MY_Controller.php on line 29

And my code is (i've marked the line that throws the error):
Code:
<?php

class Base_Controller extends Controller {

    var $where_id_escola = '';

    function Base_Controller() {
        parent::Controller();
    }

    function view($url, $data=array()) {
        // dados contactos
        $this->load->model('m_contactos');

// !!!!!! THE ERROR (LINE 29)  !!!!!!
        $data['inc_contactos'] = $this->m_contactos->get_one_where($this->where_id_escola);
        
        $this->load->view($url, $data);
    }
}

?>

<?php

class M_contactos extends MY_Model {

    var $id_escola;
    var $morada;
    var $telefone;
    var $telemovel;
    var $fax;
    var $email;
    var $gmaps;
    var $facebook;
    var $rss;

    function M_contactos() {
        parent::MY_Model();
        $this->tablename = 'contactos';
    }
    
}

?>

<?php

class MY_Model extends Model {

    var $tablename;

    function MY_Model(){
        parent::Model();
    }
    
    function get_one_where($filter) {
        $this->db->where($filter);
        $query = $this->db->get($this->tablename);
        if ($query->num_rows() > 0) {
            return $query->row();
        } else {
            $row = $this;
            $row->id = 0;
            return $row;
        }
    }
}

?>

Anyone knows why in php4, I can't call a parent function?

Thank you!
#2

[eluser]danmontgomery[/eluser]
The error says MY_Controller, your code says Base_Controller...
#3

[eluser]yabune[/eluser]
my_controler.php is the name of the filename.
what i use in the controllers is the base_controller.

it works ok in php5.




Theme © iAndrew 2016 - Forum software by © MyBB