如何检查yii2基本数据库中是否存在电子邮件,我将数据库与框架连接,但需要帮助,如何检查(忘记密码需要(表格))
答案 0 :(得分:1)
假设您要查找的电子邮件位于$ email_to_check中,ActiveRecord是YourClass应该是这样的事情
$model = YourClass::find()->where(['email'=> $email_to_check]);
If (isset($model)) {
// then your email exists
}
可能是
$modelUser = User::find()->where(['email'=> $email_to_check]);
If (isset($modelUser)) {
// then the User with your email exists
}