dede_archives是什么?如何使用?

99ANYc3cd6
预计阅读时长 22 分钟
位置: 首页 DEDE建站 正文

Of course. This is a very common question for developers working with the DedeCMS (织梦CMS) content management system.

dede dede_archives
(图片来源网络,侵删)

Let's break down dede_archives in detail.


What is dede_archives?

In simple terms, dede_archives is the main and most important table in the DedeCMS database.

Think of it as the central library or the main filing cabinet for all your website's content. It stores the core information for every single piece of content you publish on your site, such as:

  • Articles / Posts
  • Pages
  • Software Downloads
  • Products (in many basic setups)

Its name comes from the default table prefix used by DedeCMS: dede_. So, the full name is dede_archives.

dede dede_archives
(图片来源网络,侵删)

Core Purpose and Function

The primary purpose of dede_archives is to store the meta-data and content of your articles. This data is what powers your website's front-end display and the back-end management system.

When you create a new article in the DedeCMS admin panel, you are essentially adding a new row to this table. When a visitor views an article on your website, DedeCMS fetches the data for that specific article ID from this table and uses it to generate the HTML page.

Key Fields (Columns) in dede_archives

This table has many columns, but here are the most important ones you'll frequently encounter:

Field Name Data Type Description
id int(11) Primary Key. The unique ID number for each article. This is how the system identifies a specific post.
typeid int(11) Foreign Key. The ID of the category (from dede_arctype) this article belongs to. This is crucial for organizing content.
arcrank tinyint(1) Status of the article.
-1 = Deleted
0 = Published (default)
1 = Needs editorial review
click int(10) The number of times the article has been viewed (click count).
shorttitle varchar(255) A shortened version of the title, often used for SEO or in lists.
writer varchar(30) The author of the article.
source varchar(50) The source of the article (e.g., "Reprinted from...").
litpic varchar(100) The path to the thumbnail or featured image for the article.
pubdate int(10) The publication date, stored as a Unix timestamp.
senddate int(10) The date the article was submitted/created, also a Unix timestamp.
mid int(10) The ID of the member/user who created the article.
description text A brief summary or description of the article, often used for meta descriptions.
keywords varchar(255) Keywords associated with the article, for SEO purposes.
ismake smallint(6) Whether the article's static HTML page has been generated.
1 = Yes
0 = No
filename varchar(120) The filename of the static HTML page (e.g., article-1.html). This is used when "static page" mode is enabled.
body mediumtext The main content of the article. This is the largest field and contains all the text, HTML, and images.

How it Works with Other Tables

dede_archives rarely works in isolation. It's the center of a relational database structure.

dede dede_archives
(图片来源网络,侵删)

a) Relationship with dede_arctype (Categories)

  • dede_arctype stores all your category information (e.g., "News," "Tutorials," "About Us").
  • The typeid field in dede_archives links to the id field in dede_arctype.
  • This connection allows DedeCMS to:
    • Group articles by category.
    • Automatically generate navigation menus.
    • Display articles belonging to a specific category on a category page.

b) Relationship with dede_addonarticle (Extended Content)

For articles, the main body content is often stored in a separate table called dede_addonarticle.

  • Why? To keep the main dede_archives table lean and fast.
  • The id in dede_archives is linked to an aid (article ID) field in dede_addonarticle.
  • When you create an article, DedeCMS first creates a record in dede_archives with the title, author, etc., and then creates a corresponding record in dede_addonarticle with the full body content.

Example Query: To get a full article with its category name, you would need to join these tables:

SELECT
    a.title,
    a.body,
    t.typename as category_name
FROM
    dede_archives as a
JOIN
    dede_arctype as t ON a.typeid = t.id
WHERE
    a.id = 123; -- The ID of the article you want to fetch

Common Use Cases and Examples

Use Case 1: Getting the 10 Most Popular Articles

You would query dede_archives and order by the click field.

SELECT id, title, litpic
FROM dede_archives
WHERE arcrank = 0 -- Only get published articles
ORDER BY click DESC
LIMIT 10;

Use Case 2: Getting All Articles in a Specific Category

You would filter by the typeid field.

SELECT id, title, description, pubdate
FROM dede_archives
WHERE typeid = 5 -- Assuming category ID 5 is "Tutorials"
AND arcrank = 0
ORDER BY pubdate DESC;

Use Case 3: Fixing Broken Links or Images

If you migrate a site or change image paths, you might need to update the body field for all articles.

Warning: This is an advanced operation. Always back up your database first!

-- This is an example. Be very careful with UPDATE statements.
UPDATE dede_archives
SET body = REPLACE(body, 'old-image-path/', 'new-image-path/')
WHERE body LIKE '%old-image-path%';

Summary

Aspect Description
What it is The core database table in DedeCMS for storing articles and content.
Purpose Holds all the essential data (title, content, category, date, etc.) for every piece of content.
Key Fields id (unique identifier), typeid (category link), title, body, pubdate.
Relationships Works with dede_arctype for categories and dede_addonarticle for extended content.
Importance It is the heart of your DedeCMS website's content. Understanding it is crucial for customization, development, and troubleshooting.
-- 展开阅读全文 --
头像
织梦网站keywords为何显示不全?
« 上一篇 2025-12-13
谭浩强C语言第四版PDF哪里能找到?
下一篇 » 2025-12-13

相关文章

取消
微信二维码
支付宝二维码

目录[+]