Insert Database In Heirarchical Order From Yii To Database(Mysql)

Hello Yii friends …I am writing php script in Yii to insert the hierarchical database(mysql) from form. for example i have chapter 18 which contain section 18.1. where 18.1 may also have subsection 18.1.1 and again where 18.1.1 also may have 18.1.1.1, 18.1.1.2 and so on. after finishing chapter 18 again. I can do the similar for chapter 19,20 and so on…Well I am still trying but could not figure out the solution properly.

I was wondering if any of you friends have done it or know it. I will be really thankful.

database should store the value in similar order.

id — section_num – parent_section_id

1 — 18.1 ---- ----- — – 0

2 – - 18.1.1 – ----- — – 1

3 – - 18.1.1.1 – ------ — – 2

4 – - 18.1.1.1.1 ----- — – 3

5 – - 18.1.1.1.2 ---- — – 3

6 – - 18.1.2 -------- — – 1

7 – - 19.1 -------- — – 0

Thanks in Advance

Regards

Sundar

Check

http://www.yiiframework.com/forum/index.php/topic/32697-urlmanager-configuration-for-unlimited-depth-of-categorysubcateogries/

Also

http://www.yiiframework.com/forum/index.php/topic/19319-multi-parent-child-in-yii/

Well thanks for your help… I want make clear that I am not talking about url.I am saying I am writing my own code in Yii. so that I am expecting the code in where I want enter the Law. Where main is chapter and there is section and subsection under the chapter. as well as i wan to integrate even breadcrums…

Thanks

Sundar

Got your point but my aim was that you can use it to do that.

What is actually happening?

Each of your section has a sub section as do the Categories.

What you actually need is that How you can get the Parent of a child to list there i.e.

Section 1

Section 1.1

Section 2

Section 2.1

Section 2.1.1

The functions by atanio will help you in doing that.

Suggestion

Redesign your table of sections as


id Section_name path parent_section

1  18           18        0

2  18.1         18.1      1

3  18.1.1       18.1.1    2