views:

180

answers:

3

hello! 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.
+1  A: 

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
Bill Karwin
A: 

Also, I recommend to view this! http://www.pure-performance.com/2009/03/managing-hierarchical-data-in-sql/

purple
+1  A: 

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
towfx