views:

41

answers:

1

Hi everyone,

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 $this->load->view, instead of the $this which refers to the object itself.

Is it possible?

Thanks,
Lemiant

+1  A: 

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.

BoltClock
but keep in mind that you usually shouldn't do things with a controller from a model, right?
aularon
Thanks. and I will remember.
lemiant