So, in the website I’m making for my dad, I’m using CodeIgniter as the application framework. It’s pretty nice in taking care of the stupid stuff I’d rather not think about, and extending the framework is super simple when you’ve got a reason to do so.
Recently, however I’ve come across something that’s weird. In one of my controllers, I’m load two different models in the constructor. Both models are extended from a custom Model class that extends the core CI_Model class. One represents a user, and the other represents a sale listing. Nothing too fancy done. In the custom parent Model class I wrote, I wrote a constructor function which sets the default table to look at. This works fine for the User model, but not for the Sales model. Not sure if it has something to do with my code or if it’s a result of a bug with CodeIgniter so I’m going to set up a small test case later.
Update: So I was wrong. I was extending the wrong class in the sales Model. Something else did come about while I was looking into this. For some reason. When Loading two models manually and right after each other, the first loses its table details. Don’t know why, as they should be two separate objects, but it’s easily handled by doing the work with first model, and then doing the work with the second.