I think that such a quick way to determine the user name duplication is to set the user name field UNIQUE
, and then write to catch the exception.
But I tried it and found that the actual operation is not that simple. If the user name is required to be unique, just write the table to see the exception. If it is repeated, it can return false, but if it is successful, the written data will be incomplete. We What is really needed is to write the registration information submitted by the user to the table together. I thought about it and realized that this operation can only be achieved through transactions. As long as the transaction is not committed, the table will not be actually written, but we have already learned that the table Is this piece of data conflicting? I don’t know if my understanding is correct. Or it is achieved through other means. Isn’t it appropriate to judge by select
query for a large amount of data?
Isn’t it generally true that ajax will do the query after the front-end input is completed? When submitting, check it again before inserting it into the library. It is safer to be unique.
According to the name entered by the user, check the database and it will be ok. If there is a result, it will prompt that it is occupied. If there is no result, it can be used. If someone submits it first and then prompts that it is occupied while entering other information, it will be ok. Please consider your words. Yes, the probability of this is very low and it is acceptable
Check it in the database