Advertisement
tydeas_dr

Untitled

Jan 19th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. /**
  2.  * Controller define actions
  3.  */
  4. <?php
  5. class Examplecontroller extends Controller
  6. {
  7.     ....
  8.     public function actions()
  9.     {                                                                                            
  10.         return array(                                                                            
  11.             'member'=>array(                                                                      
  12.                 'class'=>'Ka',
  13.                 'model' =>'Members',
  14.             ),
  15.             'jobs'=>array(
  16.                 'class'=>'Ka',
  17.                 'model'=>'Projects',
  18.             )
  19.         );
  20.     }
  21.     ...
  22.  
  23. /**  
  24.  * CAction in components folder
  25.  */
  26. class Ka extends CAction
  27. {
  28.     public $model = null;
  29.    
  30.     public function run( $getParam = null)
  31.     {
  32.        if($this->model === null)
  33.             throw CException('Set Model name');
  34.            
  35.         $dp = new CActiveDataProvider($this->model);
  36.    
  37.         $this->controller->renderJson($dp->getData());
  38.    
  39.     }  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement