Created
May 2, 2013 21:08
-
-
Save DrMabuse23/5505482 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Updates a particular model. | |
* If update is successful, the browser will be redirected to the 'view' page. | |
* @param integer $id the ID of the model to be updated | |
*/ | |
public function actionUpdate($id) | |
{ | |
$model=$this->loadModel($id); | |
if ($model->galleryBehavior->getGallery() === null) { | |
$gallery = new Gallery(); | |
$gallery->name = true; | |
$gallery->description = true; | |
$gallery->save(); | |
$model->gallery_id = $gallery->id; | |
$model->save(); | |
} | |
// Uncomment the following line if AJAX validation is needed | |
// $this->performAjaxValidation($model); | |
if(isset($_POST['BlogPost'])) | |
{ | |
$model->attributes=$_POST['BlogPost']; | |
$model->authorName = $_POST['BlogPost']['authorName']; | |
$model->categoryId = $_POST['BlogPost']['categoryId']; | |
if($model->save()){ | |
$criteria = new CDbCriteria(); | |
$criteria->compare('post_id',$model->id); | |
$lookup = BlogPostLookupCategory::model()->find($criteria); | |
if($model->categoryId != $lookup->category_id) | |
{ | |
$lookup->category_id= $model->categoryId; | |
$lookup->update(); | |
} | |
$this->redirect($this->homeUrl); | |
} | |
} | |
$this->render('update',array( | |
'model'=>$model, | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment