CodeIgniter Forums
Is passing the same $data variable to multiple views inefficient? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Is passing the same $data variable to multiple views inefficient? (/showthread.php?tid=44171)



Is passing the same $data variable to multiple views inefficient? - El Forum - 08-05-2011

[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


Is passing the same $data variable to multiple views inefficient? - El Forum - 08-07-2011

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