I have the following database model.
Model1 hasMany Users
Model2 hasMany Users
Model3 hasMany Users
And one user can only belong to one Model. So the table user fields are the following:
id username password model1_id model2_id model3_id
I need to check in CakePHP User model that the three foreign keys cannot be NULL at the same time.
Which is the best way to solve that? Because I can't create any custom validation rules, validation rules was thought for validating one field. So How can I validate multiple fields and print the pertinent validation error.
1, 2, NULL
and1, 2, 3
, that's what @Mr.E is asking for. This multiple foreign key scheme is usually an indicator for poor database design. People might be able to give you a hint if you'd come up with a more real world example. – ndm