예제 #1
0
 /**
  * save file info in DB
  * @param char $file_name
  * @param char $model_name
  * @param int $model_id
  * @return int record id
  * @throws CHttpException
  */
 public function saveToDb($file_name, $model_name, $model_id)
 {
     $model = new D2files();
     $model->file_name = $file_name;
     $model->upload_path = 'tttt';
     $model->add_datetime = date('Y.m.d H:i:s');
     $model->user_id = Yii::app()->user->id;
     $model->model = $model_name;
     $model->model_id = $model_id;
     try {
         $model->save();
     } catch (Exception $e) {
         throw new CHttpException(500, $e->getMessage());
     }
     return $model->primaryKey;
 }
예제 #2
0
 public function actionAjaxCreate($field, $value)
 {
     $model = new D2files();
     $model->{$field} = $value;
     try {
         if ($model->save()) {
             return TRUE;
         } else {
             return var_export($model->getErrors());
         }
     } catch (Exception $e) {
         throw new CHttpException(500, $e->getMessage());
     }
 }