This article mainly introduces how to use the business logic of CodeIgniter controller, and analyzes the related concepts and specific usage of the business logic in the form of instances, for more information about the business logic of CodeIgniter controller, see the following example. We will share this with you for your reference. The details are as follows:
We have analyzed the distribution of public controllers by module to facilitate control over specific modules. the specific implementation classes are placed in the library. Is it appropriate to put it in the library? And where should we put more business logic in the controller?
First, let's talk about the understanding of several folders in CI.
The code is as follows:
$ This-> load-> service ('User _ service ');
.
However, many business logic needs to obtain the CI instance. here we can refer to the model method. The core creates a MY_Service, and all other services inherit this class, so that the usage of the service is the same as that in the controller.
Class MY_Service {public function _ construct () {log_message ('debug', "Service Class Initialized");} function _ get ($ key) {$ CI = & get_instance (); return $ CI-> $ key ;}}
In fact, the main idea is to have a layer to process the business logic, and both java have this layer. As I became familiar with CI, I found that this layer is needed to free up controllers and models. There are still many similar practices. if there are many places in the system that need to use web services or cache, you can also put them in a folder to facilitate management.