CodeIgniter Forums
Models inside Models, or...options - 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: Models inside Models, or...options (/showthread.php?tid=22529)



Models inside Models, or...options - El Forum - 09-12-2009

[eluser]Unknown[/eluser]
Hey Guys,

I'm trying to keep my database code out of my controllers and in models. Unfortunately, I have to use the Filemaker API for database access, so I can't use the built in database functionality...that would be too easy. Anyway. I have a User model that contains all my user data and db functionality. I want to be able to do something like get_users('Status','Approval Pending'), that would return an array of User Models. I tried creating a 'Users' (note the plural) model for handling groups of users, but I cannot seem to use the single User model from within it. I could do the search from within my controller, but I want to keep it DB clean.

Any ideas?

Greg


Models inside Models, or...options - El Forum - 09-13-2009

[eluser]überfuzz[/eluser]
(My guess is that you're referring to active record.) You can query a data-base with plain MySQL in CodeIgniter.

Make a model for users. users.php in that model you can put different methods; get_user() get_users() etc.