[eluser]ladooboy[/eluser]
Hi Guys,
I've come across a question which I can't seem to find an answer.
Base Controller:
Code:
class MY_Controller extends Controller{
public $data;
function __construct(){
parent::Controller();
}
function index(){}
function template($data = NULL, $result = FALSE){
if (!$this->data) $this->data = $data;
if (result){
if (!isset($this->data['header'])) $this->data['header'] = $this->load->view('includes/header', $this->data);
if (!isset($this->data['content'])) $this->data['content'] = $this->load->view($this->uri->segment(1)."/".$this->uri->segment(1),$this->data);
if (!isset($this->data['footer'])) $this->data['footer'] = $this->load->view('includes/footer', $this->data);
$this->load->view('includes/layout', $this->data);
}
else
return $this->load->view($this->uri->segment(1)."/".$this->uri->segment(1),$this->data);
}
}
Local Controller:
Code:
class Login extends MY_Controller {
function __construct(){
parent::__construct();
}
function index()
{
$this->template();
}
}
I am currently saving the data in class $data variable of MY_Controller with $this->data.
Is it probably better to use local variable and send my data object from my Login Class:
Code:
$this->template($data)
and then just use the local $data variable in my template function?
Are there any advantages, performance or efficiency wise ? Is the object being removed quicker ?