Answer the question
In order to leave comments, you need to log in
Why in yii when create in postgres swears at the uniqueness of the key?
Good afternoon,
There is such a user registration action, I get into it:
public function actionRegistration()
{
$model = new Users('registration');
if(isset($_POST['Users']))
{
$model->setAttributes($_POST['Users'], true);
if($model->save())
Yii::app()->user->setFlash('success', 'Вы успешно зарегистрировались!');
else
{
$msg = '';
foreach($model->getErrors() as $error)
$msg .= $error[0];
Yii::app()->user->setFlash('error', 'Не удалось зарегистрировать Вас <hr>'. $msg);
}
}
$this->redirect(Yii::app()->request->urlReferrer);
}
Answer the question
In order to leave comments, you need to log in
If during migration you added a bunch of users, then you need to reset the primary key counter
// @see \yii\db\pgsql\QueryBuilder::resetSequence()
$sql_resetSequence = Yii::$app->db->queryBuilder->resetSequence($table, $value);
Yii::$app->db->createCommand($sql_resetSequence)->execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question