On 4/9/05, FxParlant f-x.p@laposte.net wrote:
Thanks Richard,
It's nice you took time to answer. I'm writing an extension (another totally useless one) and I need to build a link table of the Category pages, but with the IDs. It's a complete mysql question, but I'm sure there are geeks here (as you seem to be) who know fairly well mediawiki and could help:
I need to have the cl_to and cl_from converted to the ID of these pages (exactly the same as for the normal links table)...This already gives me headaches:(
As for another constraint, I need to take into account only the links between category pages (from namespace=14 to namespace=14)
If you still have strength ... :D
François
Ok. First you'll need to create the new table. Something like:
CREATE TABLE foo ( foo_from int unsigned NOT NULL default 0, foo_to int unsigned NOT NULL default 0, UNIQUE KEY foo_from (foo_from ,foo_to), KEY (foo_to) );
Then, fill in the new table from what already exists in CategoryLinks and Cur
INSERT INTO foo (foo_from, foo_to) SELECT cl_from, cur_id FROM categoryLinks, cur WHERE cur_namespace=14 AND cur_title = cl_to
This (in effect) takes each record in the categoryLinks table and finds the matching record in cur based on a match between cur_title and cl_to. If the resulting record in cur is also from namespace 14, then it takes the cl_from in categoryLinks and the cur_id from cur and writes those as a record to the new "foo" database.
Does this do what you want? If you have any questions, please ask.
-- Rich Holton
[[W:en:User:Rholton]]