Gossamer Forum
Home : Products : DBMan : Installation :

The only one of "Title"?

Quote Reply
The only one of "Title"?
If it is possible to setup that DBMan will not creat the same "Title" name for the user info if thers is one user in the data base had creat the "Title" name. (if there is user try to creat, DBMan will tell the user that the "Title" has been taken.)
Quote Reply
Re: The only one of "Title"? In reply to
You're referring to a field in a record? If so, the way to do it would be to set your $db_key to the title field and set $db_key_track to 0. That way if another user tries to enter a title that was already entered, script will reject the record, based on a "duplicate key error."


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





Quote Reply
Re: The only one of "Title"? In reply to
Hi JPDeni :

I am just a Perl and DBMan begginer, could you show me more detail to do with this?

Where is $db_key? (In which file?) and how to set it to 0?
Quote Reply
Re: The only one of "Title"? In reply to
Look in the default.cfg file. Just below where you define the fields, there is a line

$db_key =

If the field that you don't want duplicated is called "Title", change the line so that it reads

$db_key = 'Title';

A little further down there is a line that says

$db_key_track = 1;

Change that line so it reads

$db_key_track = 0;


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





Quote Reply
Re: The only one of "Title"? In reply to
Hi JPDeni:

Thank you!

What if I need to have two fields to check duplicate, can I just add one more field name, such as:

$db_key = 'Title', 'User_Name';



Quote Reply
Re: The only one of "Title"? In reply to
Hi Aston

JPD is right...

What you can do though is the following.

In the sub validate_record (db.pl) right after
Code:
@data = &split_decode($line);
if ($data[$db_key_pos] eq $in{$db_key}) {
return "duplicate key error";}
you can add something like this...
Code:
if ($data[1] eq $in{'Field_Name'}) { return "duplicate field error Field_Name";} #unique keys for Field_Name

Field_Name is the name of the field you are trying to check on (same name as the one given in .cfg) and the [1] in $data[1] is the number of the Field_Name in your .cfg

Cheers
-JO
Quote Reply
Re: The only one of "Title"? In reply to
No. You can only have one field as the $db_key.


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