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.

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

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元