Some time ago I wrote a blog program wblog using the thinkphp framework, and then optimized it. Now I feel the strength of the thinkphp framework. In the early stage, wblog had many thinkphp features that were useless. It was based on the idea of developing the original php system. Thinkphp is a framework based on the MVC model. Generally, the business is processed on M (model), and C (Controller) only responsible for organizing the call of M processed function to return it to V (view ). However, some time ago, in order to write a blog, I used thinkphp framework to write a blog program wblog, and then optimized it. Now I feel the strength of thinkphp framework.
In the early stage, wblog had many thinkphp features that were useless. It was based on the idea of developing the original php system. Thinkphp is a framework based on the MVC model. Generally, the business is processed on M (model), and C (Controller) only responsible for organizing the call of M processed function to return it to V (view ). However, C in the previous WBLOG seems to shoulder two tasks: business processing and organization control, which violates the MVC philosophy. For example, place all functions in the public controller CommonAction. class. in php, the rest of the controllers inherit from the public controller, because there are too many functions, so CommonAction. class. php seems a little swollen, while the Model is idle and does nothing.
This time, WBlog was optimized. Each table corresponds to a Model, which is responsible for processing the related logical business. The Controller is responsible for organizing and controlling the business processed by the Model. In the previous section, "How to completely delete the tag of the thinkphp3.1 case blog? "I wrote a method to delete a tag. At the beginning, this method was put on the controller. Now we put it on the model and compare it.
The following delete function is written on the public controller CommonAction. class. php.
Public function deltag ($ recordId) {$ condition ['recordid'] = $ recordId; // get the ID of the diary $ tagged = M ('taged '); $ taggedlist = $ tagged-> where ($ condition)-> select (); // select is used instead of find, because a diary may have multiple tags $ taggedids = array (); // declare an array to hold think