If I am in a "signin" controller can I execute the method get_user_info() which resides in the "user" controller? If so, what would be the syntax for that?
If I am in a signin controller can I execute the method get_user_info() which
Share
I’m not saying this can’t be done, however it really shouldn’t be done.
Something like this is exactly what a library is meant for.
Create a library which handles functions such as
get_user_info()and then load and call that library within whichever controllers need access to it.You can still have a controller named
userand a library nameduseras well (though that could get confusing).Check out CI’s guide for info on how to create a library.
*Edit*
As people have mentioned models could also serve the purpose of making functions usable in multiple places.
Personally I like to keep only business logic within models (the CRUD operations) and any logical operations which must be done in multiple places I create a library for.