Yii Action Method Tips
An action is defined as a method named with the action Word as the prefix. The more advanced way is to define an action class and have the controller instantiate it when it receives the request. This allows the action to be reused, improving the reusability.
1, define an action class, the basic format is as follows:
Class Updateaction extends Caction{public function run () {//... Logical code ...}}
2, use the action class: In order to let the controller notice this action, we need to cover the Controller class of the actions () method as follows:
Class Postcontroller extends Ccontroller{public function actions () {return array (//using the Application Folder/controllers/post/ updateaction.php "File class to handle the edit action ' edit ' = ' application.controllers.post.UpdateAction ',);}}
As shown above, we used the path alias application.controllers.post.UpdateAction to specify the action class file as protected/controllers/post/updateaction.php
By writing class-based actions, we can organize the application into the style of the module.
Articles you may be interested in
- Eight classic tricks for Linux OS applications
- The action parameter binding processing of YII controller
- Yii database Add, modify, delete related Operations summary
- Ten tips for accelerating Win7 system optimization
- Improve database performance uncover SQL optimization tips
- Methods and techniques for studying PHP open-stream code
- A summary of query techniques in thinkphp
- The summary of Yii database query operation
http://www.bkjia.com/PHPjc/983633.html www.bkjia.com true http://www.bkjia.com/PHPjc/983633.html techarticle Yii action method Skill action refers to a method that is defined as a prefix named with an action word. The more advanced way is to define an action class and have the controller make the request when it receives ...