Welcome Guest, Not a member yet? Register   Sign In
Is passing the same $data variable to multiple views inefficient?
#1

[eluser]Unknown[/eluser]
Hi Everybody,

New to CodeIgniter and would love some clarification about best practices about passing data from the controller to multiple views.

I've queried some rows from a table and it's stored in a $data variable (following nettuts tutorials). The data holds information for all the columns. It's passed into the view like this:

Code:
$this->load->view('feature_quote', $data);
$this->load->view('page_content', $data);


My question is if passing the same $data variable into multiple views is inefficient since some of the data isn't being used. Should my controller for instance query specific columns instead so we're passing specific data into each view like below.

Code:
$this->load->view('feature_quote', $quote);
$this->load->view('page_content', $data);


Thanks in advance and sorry if this is a noob question.

Cheers,
Mike
#2

[eluser]CodeIgniteMe[/eluser]
It's fine if you pass data to your views but not all of them are in use.
if you plan to make separate variables and add process to extract them, you will only add loads to the server, which is I think what do do not want.




Theme © iAndrew 2016 - Forum software by © MyBB