Reputation: 6616
I have actually 3 questions, but similar to each other:
Permissions
. and I need another model ie. Users
. what is the proper way to user Permissions
inside Users
.Permissions
model, will be used globally throughout my application, what is the way to use it in other models or controllers (similar with 1st question)Upvotes: 0
Views: 297
Reputation: 14550
One way is to get the global variable for the main CodeIgniter object, and then load the model from that object rather than $this:
class Permissions extends Model
{
function MyPermissionsFunction()
{
$ci =& get_instance();
$ci->load->model('users');
$ci->users->MyUserFunction();
}
}
You can also sidestep the issue by combining your models together into one larger model. The main reason to keep them separate is to only load the models that you need; if you nearly always use both together (as would make sense, for Users and Permissions), you may be better off taking this approach.
Upvotes: 4