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.

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

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大