[SOLVED] Unique Update Action

I currently have a working transaction within my update action.

I am trying to run this transaction, if and only if $model->Status turns from ‘P’ to ‘A’ but not sure how to go about this. Below is my non working attempt. Anyone have any ideas?


public function actionUpdate($id) {

	$model = $this->loadModel($id, 'Model');


	if (isset($_POST['Model'])) {

		$model->setAttributes($_POST['Model']);

		

		if (isset($_POST['Status']) && $_POST['Status']=='A')   //execute transaction only if updated 'Status' is set to 'A'

		

		{	$connection = yii::app()->db;

				$transaction=$connection->beginTransaction();

			try 

			{	

				$model->save();		

				

				$connection = yii::app()->db;

                                    $sql1 = transaction...

                                    $sql2 = transaction...

                                    $command->execute();

				

				$transaction->commit();

				$this->redirect(array('/../..'));

			}

			catch(Exception $e)

			{

				$transaction->rollBack();

				$this->redirect(array('..'));

			}

		}

	else $model->save();

		$this->redirect(array('/../..'));

		

	}


	$this->render('update', array(

			'model' => $model,

			));

}

status is an attribute from your model right?

So after $model->setAttributes($_POST[‘Model’]);… you have all the data in the $model object… why then do you use $_POST[‘Status’]?

Use the $model->Status…

Thanks mdomba for the help.