Gossamer Forum
Quote Reply
Re: Importing script In reply to
Links 2.0 Flat file uses a different structure than Links SQL 2.x

First, the links in 2.0 contain the directory/category information. In Links 2.x they do not.

You would need to select out the Links records, adding in the category record, then writing out the fields in order of the Links 2.0 flatfile definitions file.

At the same time, you'd need to create a list of the categories, and create a category file that would match the definitions of the category structure.

You could use hashes to store the data, but you'd have to write it out in order, so an array or using explicitly named variable output would be needed.

If this is being imported into a new Links 2.0 flat file installation, it would not be as tricky as if it was trying to be merged into an existing one.

Depending on how large your databse was, you could do a simple select ID from Links order by ID to select out the set of links, even 20,000 links shouldn't be too much to select out 20,000 integers (I might be wrong though). Then just work through that to write out all your links.

If you have a really large database, you'd have to do it differently, using a place holder, and LIMITing your selects. (of course you could also do brute force, starting at 1 and just iterating by +1 up to the value of SELECT ID FROM Links ORDER BY ID DESC LIMIT 1 Just test to see if each "id" exists, if not, add one, and try again [or using Links methods: ($rec=$db->get($id)) or next;]

I won't say this is a "trivial" application (since I don't exactly remember the category table in Links 2.0 flat file) but it's darn close to being one. This is the sort of disposable script PERL was made for :)



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Subject Author Views Date
Thread Importing script katabd 2959 May 20, 2001, 7:16 AM
Thread Re: Importing script
pugdog 2895 May 20, 2001, 9:21 AM
Post Re: Importing script
katabd 2879 May 20, 2001, 8:13 PM