我使用" symfony / symfony":" ~2.4", 和配置
public function actionUpdate($id)
{
$model=new CvUpload;
$Updatemodel= new CvUpload;
$model=$this->loadModel($id);
$CvHistory=new CvHistory;
if(isset($_POST['CvUpload']))
{
$model_unchanged = $this->loadModel($id);
$model_changed = $this->loadModel($id);
$model->attributes=$_POST['CvUpload'];
$Updatemodel->attributes=$_POST['CvUpload']
if ($model_unchanged->user_id == $_POST['CvUpload']['user_id'] && $model_unchanged->job_title_id == $_POST['CvUpload']['job_title_id'] && $model_unchanged->file_name == $_POST['CvUpload']['file_name']){
$this->redirect(array('view','id'=>$model_unchanged->cv_id));
}
elseif($model_changed->user_id !== $_POST['CvUpload']['user_id'] && $model_changed->job_title_id !== $_POST['CvUpload']['job_title_id'] && $model_changed->file_name !== $_POST['CvUpload']['file_name'] && $model_changed->version_id !== $_POST['CvUpload']['version_id'])
{
$model_changed->save(false);
$criteria = new CDbCriteria();
$criteria->condition = "cv_id = $model_changed->cv_id AND is_current = 'yes'";
$CvHistory = CvHistory::model()->find($criteria);
$CvHistory->is_current = 'no';
$CvHistory->status = 'inactive';
if($CvHistory->save(false))
{
$new_CvHistory=new CvHistory;
$new_CvHistory->cv_id = $model_changed->cv_id;
$new_CvHistory->user_id = $model_changed->user_id;
$new_CvHistory->job_title_id = $model_changed->job_title_id;
$new_CvHistory->cv_type = $model_changed->cv_type;
$new_CvHistory->version_id = $CvHistory->version_id+1;
$model_changed->version_id = $new_CvHistory->version_id ;
$new_CvHistory->file_name = $model_changed->file_name;
$new_CvHistory->upload_date = $model_changed->upload_date;
$new_CvHistory->update_date = new CDbExpression("NOW()");
$model_changed->update_date = $new_CvHistory->update_date ;
$new_CvHistory->status = $model_changed->status;
$new_CvHistory->is_current = "yes";
$new_CvHistory->save(false);
$model_changed->save(false);
if($new_CvHistory->save(false))$this->redirect(array('view','id'=>$model_changed->cv_id));
}
}
elseif($model->save())// if
{
$criteria = new CDbCriteria();
$criteria->condition = "cv_id = $model->cv_id AND is_current = 'yes'";
$CvHistory = CvHistory::model()->find($criteria);
$CvHistory->is_current = 'no';
$CvHistory->status = 'inactive';
if($CvHistory->save(false))
{
$new_CvHistory=new CvHistory;
$new_CvHistory->cv_id = $model->cv_id;
$new_CvHistory->user_id = $model->user_id;
$new_CvHistory->job_title_id = $model->job_title_id;
$new_CvHistory->cv_type = $model->cv_type;
$new_CvHistory->version_id = $CvHistory->version_id+1;
$model->version_id = $new_CvHistory->version_id ;
$new_CvHistory->file_name = $model->file_name;
$new_CvHistory->upload_date = $model->upload_date;
$new_CvHistory->update_date = new CDbExpression("NOW()");
$model->update_date = $new_CvHistory->update_date ;
$new_CvHistory->status = $model->status;
$new_CvHistory->is_current = "yes";
$new_CvHistory->save(false);
$model->save(false);
if($new_CvHistory->save(false))$this->redirect(array('view','id'=>$model->cv_id));
}
}
}
$this->render('update',array(
'model'=>$model,
'CvHistory'=>$CvHistory,
));
}
我使用" symfony / symfony":" 2.8.x-dev",
创建新项目首先我得到错误
"autoload": {
"psr-0": { "": "src/", "Mea":"vendor/", "mea":"vendor/Mea/CoreBundle/", "Place":"vendor/Mea/" }
},
所以我添加
[InvalidArgumentException]
a non-empty PSR-4 prefix must end with a namespace separator.
并且有ClassNotFoundException
当我尝试访问此文件夹中的类时
示例:
"autoload": {
"psr-4": { "": "src/","Mea\\":"vendor/", "mea\\":"vendor/Mea/CoreBundle/", "SymfonyStandard\\": "app/SymfonyStandard/" }
},
给我
$a = \mea\pattern\view::inst();
如何解决?