示例#1
0
 /**
 * This method gets user id,specialist type id and array of data of the user to create new project data.
 * insert data into database and returns true if successful
 * Returns false if insertion unsuccessful.
 * Data array should have following hash keys
 		1.user id
 		2.project name
 		3.description
 		4.image
 		5.duration
 *
 * @param int $specialistid,array $data
 * @return model|false
 */
 public static function addSpecialistProjects($userId, $specialistTypeId, $projectsData)
 {
     $result = true;
     foreach ($projectsData as $data) {
         $specialist = new UserSpecialistProjects();
         $specialist->user_id = $userId;
         $specialist->specialist_type_id = $specialistId;
         $specialist->attributes = $data;
         $result = $result && $specialist->save();
     }
     return $result;
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UserSpecialistProjects();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['UserSpecialistProjects'])) {
         $model->attributes = $_POST['UserSpecialistProjects'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }