Welcome to Geeklog, Anonymous Thursday, October 10 2024 @ 11:37 pm EDT
Geeklog Forums
article numbering.
Status: offline
aschmidtm
Forum User
Newbie
Registered: 05/21/04
Posts: 1
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.
Started out as geeklog. I just got lazy.
Started out as geeklog. I just got lazy.
7
12
Quote
Status: offline
vinny
Site Admin
Admin
Registered: 06/24/02
Posts: 352
Location:Colorado, USA
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
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
7
7
Quote
A. Nonnimus
Anonymous
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.
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!
11
6
Quote
Text Formatted Code
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
6
5
Quote
zoombabwe
Anonymous
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!
thanks again!
5
6
Quote
zoombabwe
Anonymous
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.
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.
6
5
Quote
All times are EDT. The time is now 11:37 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content