Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Re: editing field position

Quote Reply
Re: editing field position In reply to
To expand on this:

Take a structure dump of the current links table you are using.

Move the fields around in whatever order you want.

Then, create a new links table, called something like Links_NewOrder

Then, you'd want to take each and every record in your old database, and insert it into the new database table.

Code:
INSERT INTO Links.Links_NewOrder (Title, Keywords, Description, URL, Add_Date, Mod_Date, Status)
SELECT
Title, Keywords, Description, URL, Add_Date, Mod_Date, Status
from Links.Links
order by ID

The KEY -- let me repeat here -- THE KEY!!!! --- is to list EACH AND EVERY FIELD IN YOUR ORIGINAL LINKS TABLE IN THE NEW ORDER YOU WANT IT TO APPEAR!!

Then, you copy that line to the new table, since what MySQL will do is access the database, find the records, assign the values to the field variables, then assign them to the new table IN THE ORDER THEY ARE LISTED!

The Select is position neutral, the INSERT makes it position sensitive --- meaning the first value in the select will be assigned the the first value in the INSERT, the second value to the second, etc.

If you have a fairly small database, this will not inpact your system at all, and you can test and play with it until it works.

ONE MAJOR BUG: if you hvae fields that have been 'escaped' -- ie: that use """ "'" ">" etc, then it MAY NOT WORK !! The field-to-field copy does not preserve the escape!

The only way to do that is to write a short program that steps through the table, and SELECTS each record, then INSERTS each record into the new table, after checking to see if any string needed escapes.

You might be able to use your back-up files, to do something similar. But, there are some problems with that and preserving the LinkID.

Given enough time (and I don't have much) writing a small script would not be very hard. You just have to follow the examples for preparing the fields from the existing links routines, then INSERT them, rather than ADD them, to preserve the Links ID, and iterate through the database one record at a time.

A slow, but good way to do it for very large databases that can't be sucked into memory, is to find out how many links you have, and set up a loop with a counter, looking for record 'loop_counter' until 'loop_counter>Total'
You'd take the record, and Insert it into the new table, using a variation of the above command, but using:

INSERT INTO Links_New (field1, field2, field3...) VALUES ($value1, $value2, $value3...)

If anyone wants to do it, it's really just a hack of existing Links routines, you just have to sniff them out -- records are added in the Validate and add_record routines, you can see examples of the INSERT command in Jump.cgi (it counts hits) and such.

It's TIME CONSUMING but not hard!






Subject Author Views Date
Thread editing field position widgetz 11882 Oct 30, 1999, 10:42 AM
Post Re: editing field position
Alex 11740 Nov 1, 1999, 10:27 AM
Post Re: editing field position
widgetz 11752 Nov 1, 1999, 11:41 AM
Post Re: editing field position
pugdog 11748 Nov 1, 1999, 4:38 PM
Post Re: editing field position
widgetz 11742 Nov 2, 1999, 11:44 AM
Post Re: editing field position
Ground Zero 11742 Apr 3, 2000, 11:43 AM
Post Re: editing field position
pugdog 11751 Apr 3, 2000, 11:07 PM
Post Re: editing field position
pugdog 11762 Apr 4, 2000, 9:05 PM
Post Re: editing field position
Alex 11744 Apr 8, 2000, 8:50 AM
Post Re: editing field position
Ground Zero 11736 Apr 8, 2000, 3:23 PM
Post Re: editing field position
pugdog 11754 Apr 10, 2000, 8:56 PM
Post Re: editing field position
pugdog 11746 Apr 11, 2000, 9:00 AM
Post Re: editing field position
Alex 11732 Apr 17, 2000, 7:23 AM
Thread Re: editing field position
gotze 11749 Apr 17, 2000, 10:58 AM
Post Re: [gotze] editing field position
jgkiefer 11683 Dec 10, 2002, 12:26 PM