如何编写面包屑(php kohana 框架)?

发布于 2024-09-14 10:29:07 字数 210 浏览 3 评论 0原文

这是编写面包屑代码的好方法吗?

  1. 使用mysql创建表“categories”
  2. 在必要的列“parent_id”列之后创建
  3. 如果parent_id列具有空值,则意味着该类别是父类别,否则该列父列是具有在“parent_id”列中标记的id的列,
  4. 递归查询到“从当前列开始的“parent_id”列并打印类别名称。

is this good way to code breadcrumbs?

  1. create table "categories" using mysql
  2. create after neccessary columns "parent_id" column
  3. if parent_id column have null value it means that this category is parent and if else this columns parent is a column with id which marked in "parent_id" column
  4. recursively query to "parent_id" column starting at current column and print category name.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好倦 2024-09-21 10:29:07

如果您使用其他存储分层数据的方法,面包屑会更容易。

请参阅我的演示文稿使用 SQL 和 PHP 实现分层数据的模型,了解以下示例替代方案:

  • 路径枚举
  • 嵌套集
  • 闭包表

Breadcrumbs are easier if you use other methods of storing hierarchical data.

See my presentation Models for Hierarchical Data with SQL and PHP for examples of alternatives:

  • Path Enumeration
  • Nested Sets
  • Closure Table
俯瞰星空 2024-09-21 10:29:07

您想查看修改后的预序树遍历模块

  • Sprig MPTT github.com/banks/sprig-mptt
  • Jelly MPTT github.com/AlexKupreev/jelly-mptt
  • v3 ORM MPTT github.com/kiall/kohana3-orm_mptt
  • v2 ORM MPTT dev.kohanaframework .org/projects/mptt

You want to check out Modified Preorder Tree Traversal modules

  • Sprig MPTT github.com/banks/sprig-mptt
  • Jelly MPTT github.com/AlexKupreev/jelly-mptt
  • v3 ORM MPTT github.com/kiall/kohana3-orm_mptt
  • v2 ORM MPTT dev.kohanaframework.org/projects/mptt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文