update and create on update

hi!

I would like to do the following: in views/project/update.php, when I click save button, instead of updating the record, I would like to update a datetime field in the database for the actual record, and then insert all values again into the database. I tried to mix update with create but suddenly the form just disappeared, so it’s a little bit beyond my knowledge for now…

somebody please?

That should work. Depends on how you mixed the 2 actions. Can you post what you’ve done?




		$model=$this->loadModel($id);

		if(isset($_POST['Mrsk2']))

		{

		   $model->mrsktd = new CDbExpression('NOW()');

		   $model->save();


		$model=new Mrsk2;


			$model->attributes=$_POST['Mrsk2'];

			if($model->save())

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

		}


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

			'model'=>$model,

		));



this way it’s working!!! I tried it once more and I managed to get the logic! I’m so happy!

Hey, this:




$model=$this->loadModel($id);

$model->mrsktd = new CDbExpression('NOW()');

$model->save();



part seems to be working, so this update is running, what is very interesting, because in this thread, this was my problem that this update was not working without this:




$model->save(false);



very interesting…

now I need one more thing. how can I achieve that this update and insert only run, when there is something changed compared to the original values? okay this is a different problem so I put it into a new thread.

Hi All,

       	i am new in yii framework ple help me ... i am using two model(users, authassignment)   how to update/create two action in one controller if i include authassignment model field in user model so the user model updating time authassignment model will create .... this is i need

sorry for my english

thanks