![]() |
Helper Library Plugin - Explain - 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: Helper Library Plugin - Explain (/showthread.php?tid=10183) Pages:
1
2
|
Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Yash[/eluser] Hi, Helper ?? Library ?? Plugin ?? View - Client side part Model - Used for database query[s] Controller - site architecture Can anyone help me to understand when we know that this should be kept as helper/plugin/library. Thank you Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Pascal Kriete[/eluser] Libraries, helpers, and plugins are used for code that you need in different parts of your applications. The same way that you use the native libraries and helpers throughout the app. Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Yash[/eluser] No my question is when we know that this code is part of helper or library. Is there any special rules or whatever author feels is right? Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Pascal Kriete[/eluser] Do what you feel is right. I personally put a lot of my code into libraries - keeps the controllers clean. It's also easy to trace because you have the classname right there in the call $this->classname->function(), that isn't the case with helpers. My helpers tend to be very general, whereas my libraries have a much more defined purpose. Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]nmweb[/eluser] Also, models are not used solely for database queries. From Wikipedia: Quote:ModelModels encapsulate the data access layer. So, you ask the model to give you the last ten articles and the model gives them to you, you don't have to know where the articles are stored and how, might be a database, text file, session or rss feed etc. Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Bramme[/eluser] I personally put lots of stuff in models. Mostly stuff that has to do with the database etc, but also $_POST handling... Like inparo I only use helpers for very general smaller things I would need over different applications. I use models for bigger stuff which is application dependent and libraries are, like helpers, for things you could use on different applications but which need a tad bigger approach, like a small auth library I wrote myself... Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Yash[/eluser] great inputs..thanx a lot guys Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]nmweb[/eluser] $_POST handling should be done by the controller, but typically $_POST should just be forwarded to the model. The model should have no awareness of it being $_POST or just a random array. Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]Yash[/eluser] nah.. we don't need $_POST you can directly access input values using input class Helper Library Plugin - Explain - El Forum - 07-22-2008 [eluser]nmweb[/eluser] Point still stands. Models should not access user input directly through either $_POST or the input class, user input is passed from the controller to the model. |