S
S
Sergey2015-03-12 01:10:15
Yii
Sergey, 2015-03-12 01:10:15

How to update records in db in yii2?

Why does it not update the record, but makes a new one, driving in only the password?
How to update an entry?

$db = new user_login;
                $res = $db->findOne(['email' => $mail]);
                $pass = md5($pass);
                $db->pass = $pass;
                $db->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sanex3339, 2015-03-12
@butteff

try like this:

$model = user_login::findOne(['email' => $mail]);
$pass = md5($pass);
$model->pass = $pass;
$model->save();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question