I have a table in db with the fields
-----------------------
Id | Value | Path | Parent
-----------------------
1 | Asia | 1 | 0
2 | India | 1/2 | 1
3 | Goa | 1/2/3| 2
The list has all the cities of the World. So its Quite a big list.
The Issue
If My product has all the parents selected for a leaf. [eg, ID 3, 2, 1 for ID:3] Than I can get generate a tree based on the ParentID
using AJAX function.
But
I select a product which gives me the leaf of the tree. [eg, ID:3 ] So I need to parse to generate the tree using Path
which sounds too bad an idea [Parsing string will be slow.]
Is there any generic solution to this thing? - Can I create a view and store the corresponding parents r.f leaf.? - Using PEAR Tree?
Or any other better solution involving the DB
directly.?
EDIT
Tree structure:
Asia
>India
>Goa
EDIT
Recursive functions by parsing the PATH
is not suitable for this job. That will be slow.