Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-10-22 23:33:12

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Update the Article ID Number (SQL)

Is there a way to update the article id# with an sql query (or something)? Something that would count all records in the textpattern table, then renumber the ID for each record, starting at 1? The reason I ask is because I’ve deleted most of a section, so my article ID’s range from 20-200, but there’s ~100 articles actually posted, so the numbering is inaccurate (plus you don’t know how much you’ve posted based on the ID#). I don’t use the /section/ID/title URL’s either.

I can do it manually of course, but I wanted to see if there was an easier way.

Offline

#2 2006-10-23 02:16:40

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Update the Article ID Number (SQL)

You would also have to redo all your comments if you have them enabled. The article id# is how they are all tied together. There wouldn’t be any way to do this with a query, you’d have to do it by hand, comment by comment.

In the end, it’s not likely to be worth the trouble.

Now, if you really want to do this, backup first. This is not supported, so if you break something… What you’d do is drop the ID field, then add it back and MySQL should re-number everything.

Offline

#3 2006-10-23 02:36:49

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Update the Article ID Number (SQL)

I deleted all my old comments awhile ago (and kept them disabled), so that’s OK.

That worked great! I was just about to do it manually – so glad you posted! 97 articles :)

Here’s the query phpmyadmin gave out too, for future reference (after exporting):

ALTER TABLE `textpattern` DROP `ID` ;
ALTER TABLE `textpattern` ADD `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;

Offline

Board footer

Powered by FluxBB