I have a Users table in which no two same users can exists , what is the best way to do this error free?
What I did is that I wrote a check for duplication in the controller, but someone said to me it’s not a right thing to do. He said put unique on database table? I have implemented this on several other controllers as well. Do I ought to change it?
There are several places where you should do this.
— edit —
It is suggested to place all three for better validations. Inconsistent data is the worst thing for your system than anything else. Because what I think is, correct data = good quality
— end edit —
please keep in mind that validation code should be placed at model and to learn how to write manageable OO code you can see example of mvc store front.
hope this will help