Reputation: 317
How I can check if an email exist in the data base in yii2 basic , I connect the database with the framework,but need help ,how to check this (its needed for the forgot password (form) )
Upvotes: 1
Views: 136
Reputation: 133370
assuming the the email you are looking for is in $email_to_check and the ActiveRecord is YourClass should be somethings like this
$model = YourClass::find()->where(['email'=> $email_to_check]);
If (isset($model)) {
// then your email exists
}
could be
$modelUser = User::find()->where(['email'=> $email_to_check]);
If (isset($modelUser)) {
// then the User with your email exists
}
Upvotes: 1