hi
there are some basic rules i don’t understand - honestly, there’s a lot in php/oop i don’t understand
i hope you can help me. in this case ME is involved.
default_controller
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Default_controller extends Controller
{
public $data;
function Default_controller()
{
parent::Controller();
$this->load->model('my_model');
}
function index()
{
$this->data = 'some text';
$this->my_model->add_text();
echo $this->data;
}
}
?>
my_model
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class My_model extends Model
{
function Model()
{
parent::Model();
}
function add_text()
{
$this->data .= ' ...and some more text';
}
}
?>
results:
some text ...and some more text
$this->data passed to my_model
another_controller (calls default_controller as module)
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Another_controller extends Controller
{
function Another_controller()
{
parent::Controller();
}
function index()
{
echo modules::run('default_controller');
}
}
?>
results:
some text
$this->data NOT passed to my_model. why is that? how can i make $this->data pass to a model when in a module? maybe it’s just a bad idea?
thank you.
