In Yii2 I have two fields in my Database: email
and shopId
-
Email
andshopId
should beunique
together -
Email
could also beempty
(NULL
) whileshopId
is always an integer
These are my rules in the Model:
[['email'],'default','value' => NULL],
[['shopId'], 'integer'],
[['email','shopId'], 'unique', 'targetAttribute' => ['email', 'shopId'], 'message' => 'Already taken!'],
This is not working when I have two entries with e.g. email="NULL"
and shopId="1"
.
How can I solve this?