Home  >  Article  >  Backend Development  >  怎么写tags,能否给个思路?

怎么写tags,能否给个思路?

WBOY
WBOYOriginal
2016-06-06 20:52:27936browse

tags,就像SF每个问题下面的标签功能,是怎么写的?
是否是每次添加tags,然后就在数据库中tags表中查询,没有的话就添加?能否给个明确的思路呢,谢谢

回复内容:

tags,就像SF每个问题下面的标签功能,是怎么写的?
是否是每次添加tags,然后就在数据库中tags表中查询,没有的话就添加?能否给个明确的思路呢,谢谢

查询放在搜索引擎里的,用 “,” 做分词

建一个标签表 tags,字段有 id 和 name 再建一个标签关系表 articletag,字段为 articleid 和 tag_id

添加标签的时候就查询tags表,如果已存在就拿到tagid,如果没有就添加新标签并拿到tagid 最后把文章和标签的关系存入article_tag表即可。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn