CodeIgniter Forums
same code in two functions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: same code in two functions (/showthread.php?tid=12327)



same code in two functions - El Forum - 10-15-2008

[eluser]Mitja B.[/eluser]
i have some file news.php and view function news()

In it i have <?php $this->load->view("header"); ?>. In header i also have some sql code. Now i need in news function add code which is in header function. How i can make that this will not be necesary.


same code in two functions - El Forum - 10-15-2008

[eluser]meigwilym[/eluser]
Hi Juve,

Any SQL should be in a model. A controller can call the model and get its data, and then pass it to a view file.

If you take a look at Derek Jones' excellent blog tutorial, it should give you a good grounding in the MVC process:

http://codeigniter.com/tutorials/watch/blog/

Regards,

Mei


same code in two functions - El Forum - 10-15-2008

[eluser]Mitja B.[/eluser]
meigwilym thx you i will use model for this. But in tutorial you gave me, author never use model, just controler and view.