Home  >  Article  >  Backend Development  >  Form validation in CI - unqiue

Form validation in CI - unqiue

WBOY
WBOYOriginal
2016-09-02 08:57:061287browse

When it comes to is_unique in form validation, it goes directly to the database to query, but I want to exclude myself, what should I do?
For example, my username (unique field) is Beetle and the id is 1. When modifying user information, if I use unique directly, it will directly prompt that it is occupied. How can I exclude myself and check the uniqueness? That is, such a sql To verify the uniqueness - select username from xxx where username='Beetle' and id!=1
Thank you everyone

Reply content:

When it comes to is_unique in form validation, it goes directly to the database to query, but I want to exclude myself, what should I do?

For example, my username (unique field) is Beetle, and the id is 1. When modifying user information, if I use unique directly, it will directly prompt that it is occupied. How can I exclude myself and check the uniqueness? That is such a sql To verify the uniqueness - select username from xxx where username='Beetle' and id!=1
Thank you everyone

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn