php - In Yii, how do you validate uniqueness against another column in the table? -


i giving users ability change account email. so, when submit new email switch to, storing email in database temporary email. once user clicks on confirmation email sent new email, original email change new email. in "users" table, have column, "email," , one, "temp_email." when user submits new email "temp_email" column, validate unique not within "temp_email" column, within "email" column.

currently, have these 2 arrays in rules() function:

array('temp_email', 'email'),
array('temp_email', 'unique', 'message' => usermodule::t("this user's email address exists."))

which temporary email has in email format , cannot same other temporary email. third array must add saying temporary email cannot same other email in "email" column? thank you!

you can add additional attributes rule specify exact rules unique checking

array('temp_email', 'unique',       'classname' => 'user', 'attributename' => 'email',       'message'   => "this user's email address exists."), 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -