[eluser]Unknown[/eluser]
I have written a hook, that makes layouts for me, but I've to take some data from others controllers than I'm execute right now. According another thread on the forum in the hook I've got:
Code:
include_once(BASEPATH.'application/controllers/nameOfController.php');
$controller=new $nameOfController();
$controller->action();
It's working unless I'd like to call a model, and execute a query.
In controler's action, that I'd like to call i've got:
Code:
$CI=get_instance();
$CI->load->model('someModel');
$someData=$CI->someModel->getSomeData($someId);
return $CI->load->view($someId,$items,true);
In model I've got very simple code:
Code:
$this->db->query('set names utf8;');
$someDataResource=$this->db->query("
select * from articles;
");
return $someDataResource->result_array();
I get an error that I don't have atribute db.
When I call the controller and action by URI it works.
I think, that the problem is initialization of controller, but I don't have any idea how to solve the problem.