制作无限子类别的最佳方法是什么 [英] what is the best method to make unlimited sub catgories

查看:37
本文介绍了制作无限子类别的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这篇文章 关于方法,但是这个方法不是很好,因为它会循环数百万次 sql 查询.

I have this article about the method, but this method is not really good because its loop the sql query millions times.

有人知道使用相同 MySQL 结构的任何其他方法吗?

Anyone knows any other method using the same MySQL structure?

CREATE TABLE IF NOT EXISTS `jooria_categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` text COLLATE utf8_bin NOT NULL,
  `sub` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1;

推荐答案

有四种广泛使用的方法可以做到这一点:

There are four widely used methods to do this:

邻接表(你帖子中的那个)是最方便的,但是它需要支持MySQL缺少的递归查询,尽管它可以在一定程度上被模拟:

Adjacency list (the one in your post) is the most convenient however it requires a support for recursive queries which MySQL lacks, though it can be emulated to some extent:

这篇关于制作无限子类别的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆