2.数据库的规划
------------------------------------------------------------
前面谈到分类的复杂性,因此如何规划数据库便成为了实现无限分类非常重要的一步.
我曾介绍过论坛的数据库规划,不错论坛能够实现无限的跟接,无限分类便是这种形式的扩展,分类同样是这种子父的关联关系,所以分类的数据库就是如何确立明确这种子父关系,这里面有几个难点.
1)如何处理各分类的信息存储;
2)如何处理分类的亲缘关系;
3)如何处理对信息的查询;
亲缘关系的数据库处理与论坛的数据库处理类似,这里建个 type 的数据库用来处理分类:
建立字段:
id(int):用来记录各分类的自然序号
uid(int):用来记录该分类的父分类的 id 号
type(char):类别的名称
roue_id(varchar):亲缘树,以 :0:2:10:20: 的 id 连接表明亲源关系
roue_char(varchar):亲缘树,类似 :系统:linux:开发工具:gcc: (这个字段有没有都没关系,为了更方便地了解各亲缘关系当然字符表述比数字表述更直接^o^,不过最好加上这个字段)
这样一个无限分类的类别表就建立了起来,接下来就需要建立存储信息的数据库,处理查询一个表最方便所以这里建立一个表存储信息 type_message:
id(int):信息的序号;
typeid(int):所属类别的 id 号;
title(varchar):信息标题;
message(text):信息内容;
time:信息建立的时间;
这两个数据表就能够完成无限分类的这个任务了(两个表的辅助字段就没加了,读者可自行加入).
剩下的任务就全部交由 php 来处理完成.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
