Yii action methods and techniques. Yii action method skill action refers to a method defined as a prefix named with action words. The more advanced method is to define a category class and let the controller send the Yii action method when receiving the request.
An action is defined as a method named with the action word as the prefix. The more advanced method is to define a handler class and let the controller instantiate the class when receiving the request. This allows the action to be reused, improving the reusability.
1. define a category. The basic format is as follows:
Class UpdateAction extends CAction {public function run () {//... logic code ...}}
2. use the actions class: to let the controller notice this action, we need to overwrite the actions () method of the controller class in the following way:
Class PostController extends CController {public function actions () {return array (// use "application folder/controllers/post/UpdateAction. php "file class to process the edit action 'edit' => 'application. controllers. post. updateaction ',);}}
As shown above, the path alias application. controllers. post. UpdateAction is used to specify the handler class file as protected/controllers/post/UpdateAction. php.
By writing class-based actions, we can organize applications into a module style.
Articles you may be interested in
- Eight typical Linux operating system applications
- Yii controller action parameter binding
- Yii database addition, modification, and deletion operations summary
- Top 10 tips for accelerating Win7 system optimization
- Improve database performance Secret SQL optimization skills
- Methods and techniques for studying php open source code
- Summary of query techniques in ThinkPHP
- Yii database query operation summary
Http://www.bkjia.com/PHPjc/983633.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/983633.htmlTechArticleYii action method tip action is defined as a method named with action words as prefix. The more advanced way is to define a handler class and let the controller...