OOP? |
[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!
[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.
[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.
[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! |
Welcome Guest, Not a member yet? Register Sign In |