Geting Values From Url And Inserting It On Save()

This is my url:

localhost/adi/index.php?r=comments/create&type=Affiliate&sid=2&memid=ADIDOM1430002

I want to get the values from url in the _form of respective model(Comments) and when save is insert these values in table along with some values which are filled in the form.

And in actionCreate method of controller, can I return them in $_POST[comments], so that my task becomes easy!!

Have you looked at http://www.yiiframework.com/doc/api/1.1/CHttpRequest#getParam-detail ?


$type = Yii::app()->request->getParam('type');





public function actionCreate()

{

     $model=new Company;

   if(isset($_POST['Company']))

   { 

      $model->attributes=$_POST['Company'];


       if(!empty($_GET)){


         $model->setAttribute("type",Yii::app()->request->getParam('type'));

         $model->setAttribute("memid",Yii::app()->request->getParam('memid'));

       }

       $model->save();

   }

}

Friendly reminder: please don’t encourage people to access superglobal arrays directly.

How to write secure Yii applications

Thanks buddy, it worked!!