开发者

How can you use $this reffering to the controller in a codeIgniter model

开发者 https://www.devze.com 2023-01-14 00:18 出处:网络
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 whic

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,

Lemiant


You 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消