Gossamer Forum
Home : Products : DBMan : Customization :

Changing db_key to User ID

Quote Reply
Changing db_key to User ID
Hi. I have a problem. I am working on a database that already has over 100 users. But now I have found that I should have made the userid the db_key. Currently the db_key is a number and I have db_key_track turned on. The reason I want to change the key to the userid is because I want to limit users to one record per account. I can not find any posts that explains how to do this unless the db_key is the userid. If I do change it, will it corrupt by database? If so, how can I do it safely? Or, even better, how can I limit users to one record without changing the db_key to the userid?
Quote Reply
Re: Changing db_key to User ID In reply to
One suggestion is to change the following codes in the sub add_record routine in the db.cgi file:

Code:
if ($counter++ > 50);

to the following:

Code:
if ($counter++ = 1);

Don't gaurantee this will work...but you can give it a shot.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.
Quote Reply
Re: Changing db_key to User ID In reply to
hmm, I hope I don't have users with more than one, but since there is nothing stopping them, you never know. Any quick way to check for that?
Quote Reply
Re: Changing db_key to User ID In reply to
Do you have users who have more than one record in the database? If not, you can just change the value of $db_key in your .cfg file and set $db_key_track to 0.

If there are users who have more than one record in the database, you'll need to go through and delete those extra records first.


------------------
JPD






Quote Reply
Re: Changing db_key to User ID In reply to
I don't know how quick it would be. The only thing I can think of would be to search for each user. That would take some time.

Or you could do a "List All" and set the sb= to the number of your userid field. Then you could scroll through the records and see if there was anyone with duplicate records.


------------------
JPD