Posted on: 05/21/04 01:22am
By: aschmidtm
I need a way to assign a unique id # (starting at 00000001 and up to 99999999) to every article, except replies and/or comments to the article given the unique id #. I would like to be able to refer back to an article just by typing in an 8 digit number. Has anyone seen this or know how to get started. I would appreciate any knowledge.
article numbering.
Posted on: 05/24/04 08:28pm
By: vinny
I don't know of anyone who has done this, but if you feel brave you could probably hack up COM_makesid() in lib-common.php to accomplish approximately what you want.
Alternatively you could just add a column to the gl_stories table that auto increments and assign values 0, 1, 2, 3, ... to your existing stories.
-Vinny
article numbering.
Posted on: 10/06/04 02:44pm
By: Anonymous (A. Nonnimus)
[QUOTE BY= vinny] Alternatively you could just add a column to the gl_stories table that auto increments and assign values 0, 1, 2, 3, ... to your existing stories. [/QUOTE]
How should this be done in Geeklog 1.3.9sr1? I tried the following statement:
ALTER TABLE gl_stories ADD COLUMN article_number SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT;
and I got the following error:
ERROR 1075: Incorrect table definition; There can only be one auto column and it must be defined as a key
So how should I add this auto-incrementing column to the gl_stories table, starting at number 1 and going up?
Thanks for any advice!
article numbering.
Posted on: 10/10/04 09:44pm
By: vinny
ALTER TABLE gl_stories ADD COLUMN article_number SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD KEY (article_number);
The above is the SQL you are looking for (or something similar). What you were missing is the "add key" portion which is necessary for an auto_increment field.
-Vinny
article numbering.
Posted on: 10/11/04 01:26pm
By: Anonymous (zoombabwe)
thanks a lot for the reply, vinny...now, is there any way to make this number stick? for instance, if a number gets assigned to a story, and then the story is subsequently edited, the number ticks up again. (if i edit story 1, and my most recently added story is story 10, the edited story 1 becomes story 11.) is there a simple SQL way to do this?
thanks again!
article numbering.
Posted on: 10/11/04 10:43pm
By: vinny
I don't see this behavior. For me the auto increment value stays.
-Vinny
article numbering.
Posted on: 10/12/04 08:38am
By: Anonymous (zoombabwe)
really, it stays the same? i wonder if i should upgrade (or downgrade!?) MySQL. I'm using 4.0.18. I've tried ADD KEY, ADD INDEX, and ADD UNIQUE, and the auto_increment value ticks up if either a story or a draft story is edited.
It also ticks up if a story is deleted, but I would kind of expect that, and I figure there's nothing to do about it except reset the auto_incrementing column...
thanks for your reply vinny.