Anybody know how to set field to be unique in db?

16 years 7 months ago #43811 by reddevil4
Hi all, anybody know whether is it possible to set additional field that i have added under Components > CB > Field Management to be unique so that there will not be records in the databse to have the same value for a field.

For example, i am setting up a site whereby users can sign up to be members. During registration, i will require them to provide with their identification number. As identification number is unique to everryone, i like to make use of it so that each person can only sign up for one account.

The unique value is similar to the one that the CB have when user sign up and the system check the database for unique Username and email address.

anybody can help me out with it?

Please Log in to join the conversation.

16 years 7 months ago #43869 by reddevil4
can anyone please help me with the problem? i need to solve it urgently. May i know whether i can made the fields mandatory by editing the backend code(by unzip-ing the com_profiler) so that i can have field that can be unique in the database?

Please Log in to join the conversation.

16 years 7 months ago #43987 by nant
reddevil4 wrote:

can anyone please help me with the problem? i need to solve it urgently. May i know whether i can made the fields mandatory by editing the backend code(by unzip-ing the com_profiler) so that i can have field that can be unique in the database?


dont think you can solve this urgently - well at least gracefully ..

one potentially fast approach (you would need to test this on your own in your test environment) would be to manually alter the field column in your comprofiler table in your database using phpmyadmin to force column values to be unique (unique key in SQL).

This would ensure that only unique values are saved to the database but in case that someone enters a duplicate value then most likely a nasty error will appear that most end users will not be able to understand.

A better solution would be to write (or hire someone to write for you) a cb plugin that checks the value of this specific field against other users and gracefully rejects it if a duplicate value already exists.

If you have a real budget the second approach is good.

Post edited by: nant, at: 2007/08/24 15:00

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.143 seconds

Facebook Twitter LinkedIn