dongyou2635 2012-08-20 13:00
浏览 51
已采纳

MediaWiki文本表如何连接到类别表?

I am trying to find corresponding text records for a category.

For example if I have the ID 5 for a "categorylinks" record, how would I find which texts go into that category?

  • 写回答

1条回答 默认 最新

  • douxian3828 2012-08-20 16:20
    关注

    Edit: I'm still not sure if you are asking for the text of a category page or the text of the pages in a category so here's both:

    Text of a category page:

    select old_text from text, revision, page, categorylinks
    where rev_text_id = old_id
        and rev_id = page_latest
        and page_namespace = 14
        and page_title = cl_to
        and cl_from = <cl_from entry in categorylinks table>
    

    Text of a page in a category:

    select old_text from text, revision, page, categorylinks
    where rev_text_id = old_id
        and rev_id = page_latest
        and page_id = cl_from
        and cl_to = <cl_to entry in categorylinks table>
    

    More explanation:

    Basically, in categorylinks, the cl_title is the title of the category page. So you can look that up in the page table using page_title and page_namespace = 14 (the category namespace). Once you have the correct page, the page_latest field for that row equals the rev_id in the revision table. This gives you the latest revision for the category page. The revision table has a rev_text_id field which equals the old_id field in the text table. old_text in the text table is your text.

    Any time you want the text for a page it basically works like this. Find the page database record. Then: page.page_latest = revision.rev_id and revision.rev_text_id = text.old_id.

    See also: The MediaWiki database schema.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含