How can you use $this reffering to the controller in a codeIgniter model
I am using CodeIgniter, and in one of my models I would like to refer the $this
which is used in $this->load->model
and $thi开发者_StackOverflow社区s->load->view
, instead of the $this
which refers to the object itself.
Is it possible?
Thanks,
LemiantYou won't be able to use $this
to refer to anything but the model object itself, meaning you won't be able to do $this = ...
.
But you can get the controller instance using the following function:
$controller = &get_instance();
As aularon reminded though, if your application is designed such that you have to access your controller from a model, then perhaps you might want to rethink its implementation.
精彩评论