![]() |
OOP? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: OOP? (/showthread.php?tid=49033) |
OOP? - El Forum - 02-06-2012 [eluser]Unknown[/eluser] Hey there! I've been using CodeIgniter for a little bit now, but I'm still learning quite a bit. However, I've recently run into something of a hiccup... OOP. How would one go about doing object-oriented programming with CodeIgniter? I understand that CodeIgniter is OOP in and of itself. However, what if I want to make, say, a member class. Where would I put it? How would I load new members? With libraries, for example, I know that I can load a library, but how would I write something along the lines of "$person = new Member($member_id);" ? Thanks! OOP? - El Forum - 02-06-2012 [eluser]aleul[/eluser] Extending 'CI_Model' these represent objects that act a a 'middleman' for interacting with the db. Take a quick look at MVC design patterns to get an overview of it. OOP? - El Forum - 02-06-2012 [eluser]CroNiX[/eluser] You would create a "members" class and put it in the /application/libraries directory. Instead of: $person = new Member($member_id);” You would: Code: $this->load->library('members', $member_id); //$member_id gets passed to the __construct method of the members class. OOP? - El Forum - 02-06-2012 [eluser]Unknown[/eluser] That second example looks like it's what I want. I was unaware you could load something directly into a variable that way. Thanks! |