Gossamer Forum
Home : Products : DBMan : Installation :

Auto ID number

Quote Reply
Auto ID number
Hi,
I need to make an auto generated number on ID field.
What solutions or tips ?

Stéphane
Quote Reply
Re: Auto ID number In reply to
Right after your table definition in default.cfg:

$db_key = 'ID';

If that field is defined as 'numer' in the table definition I think it will keep count automaticaly. You can reset the count by opening default.count and replacing the value with 0
Quote Reply
Re: Auto ID number In reply to
I forgot one important detail:

$db_key_track = 1;

this is what makes DBMan keep track of the key.
Quote Reply
Re: Auto ID number In reply to
Re,
but how to mout the new ID (it's the last ID + 1) value in html in sub html_record_form

Stéphane
--
Etudiant / Student
Centre de compétence Thématique
du CNRS
Stratégie d'informatisation des données
en Archéologie.
Service Informatique de Recherche en Archeologie (SIRA)
Maison de l'archeologie
Universite Michel de Montaigne - Bordeaux 3
33405 Talence Cedex
France

www : http://www-sira.montaigne.u-bordeaux.fr
Travail de recherche : http://www-sira.montaigne.u-bordeaux.fr/boisset/
e-mail : spouyllau@montaigne.u-bordeaux.fr
Mobile : 06 84 412 897
Tel : 05 56 845 052
ICQ : 18877706

Webmaster filiere Documentation d'Entreprise et
IUT Michel de Montaigne - Bordeaux 3
www : http://www.iutb.u-bordeaux.fr
CyberDoc : http://www.iutb.u-bordeaux.fr/doc
Tel : 05 56 844 446 (repondeur)

Webmaster Reseau Amerique Latine (GIS)
www : http://www.reseau-amerique-latine.fr
-----------------------------------------
Et pourtant, elle tourne...
-----------------------------------------
Quote Reply
Re: Auto ID number In reply to
re,
well, this var ($db_key_track = 1 Wink

??? where ??? in *.cfg or

Thanks

Stéphane
Quote Reply
Re: Auto ID number In reply to
Just below the field definitions in the default.cfg file are the following lines:

Code:
# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'ID';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# necessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 1;

Set $db_key to the name of the field where your key will be held. Leave $db_key_track set to 1.

The value is set automatically. You will need to have an input field (although it can be hidden) in html_record_form to hold the ID.

In html_add_form, there is a line

&html_record_form (&get_defaults);

The "&get_defaults" part of the line calls a subroutine that sets any default values you may have defined in the .cfg file and also gets the next ID number. It then passes all the values to the form and puts them into the right fields -- assuming you have the correct field names on the fields.


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





Quote Reply
Re: Auto ID number In reply to
You don't have to worry about that. Just check the 2 lines I mentionned. There's nothing else to do. The program will keep count and when you add a new record the number will be generated automaticaly.

Those 2 lines are after the database definition in default.cfg
Quote Reply
Re: Auto ID number In reply to
WONDERFULL !!!!!!!

Thanks !!!!!!!!! :-)

Stéphane