Jump to content
Larry Ullman's Book Forums

Updating An Existing Row


Solid
 Share

Recommended Posts

Hi all.

 

Im trying go abit beyond the chapters of the yii-book, and im struggeling with the update of a database.

I cant seem to figure out how i update an existing row.

 

So im trying to build a e-mail verification, a user registers and gets an email with a link to myproject.com/verify?id=ID&verificationcode=VERIFICATIONCODE, and the verifypage picks it up and runs my actionVerify() method:

 

 

public function actionVerify() {

$model=User::model()->findByPk($_POST['id']);

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

if($model->validate())

{

Yii::app()->user->setFlash('validated','<h2>Your E-mail is validated!</h2><p>You can now log in using the form below.</p>');

$model->save();

$this->redirect(Yii::app()->homeUrl/login);

}

}

 

I've tried for a few hours now, starting of with using $model = new User, that ofcourse generates an error as you cant update an existing row with the creation of a new object. The code i have pasted over here generates the following error: Undefined index: id

 

So im kinda stuck here, and im sure the solution is close to something i've tried.

I have googled this alot, but the lack of well-explained articles kills me. I just dont have the understandment of yii/oop to use the manual or short articles just yet.

 

Any help is appriciated, thanks in advance.

Link to comment
Share on other sites

 Share

×
×
  • Create New...