CodeIgniter Forums
Help me to understand models - 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: Help me to understand models (/showthread.php?tid=47751)



Help me to understand models - El Forum - 12-21-2011

[eluser]prezet[/eluser]
Hi - I'm new to MVC, I understand the approach, but I'm getting confused with models and database interaction in general.

I understand that models act as the db interaction layer - however, how does this apply when creating your own libraries. Should db interaction within a library be abstracted out to a model, or should it encapsulate that interaction within the library itself?

Also, I've been poking through 'models' I've found on Github to get some understanding - and notice some developers have methods in their models that do no db interaction at all - such as password generation.

Please can you help me understand when/where to use a model, and when to decide with methods to put in it, and which belong in a library/alternative.

Thanks for your time.