Hello! I decided to create categories with infinite nesting. Of course in practice will not exceed 5.

There is a base

With columns: id, name, url, parent .

And url http://site.ru/catalog/category/category/category

How to correctly identify the current category by checking all parental existence? Maybe there are ready solutions for codeigniter?

Everything would be simple if the url had their id. How to do here?

You need to get the id categories, check the chain for correctness and not to create a strong load on the database.

  • And what is it for you ??? Ie sense to check? - navi1893
  • @ navi1893, what if 2 child categories come across with the same url? For example, localhost / computer / other and localhost / tv / other . Same there will be absolutely 2 different categories. Or is there some other algorithm? - alex159
  • > How to correctly identify the current category by checking all parental existence? Going cycle up (or down) one at a time and giving 404 on a mismatch. There are no other options, as far as I know. - etki 2:01 pm

1 answer 1

Solved. Going cycle up (or down) one at a time and giving 404 on a mismatch.