Codeigniter Nested Database Data -


i google , google , read 100000 tutorials think inposible in codeigniter on model, controller , views.

am tring show database records :

default category    |----- sub category           | ----one more category                |----- somthing else  

i try lft , rgt cols realy dont understand concept.

i read , try function optimize in codeigniter model work in model. http://www.sitepoint.com/hierarchical-data-database-2/

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

i have simple db sheme : categories cols id, parent_id, title

any1 can give me 1 simple example... please

thanks

assuming follow basic table structure:

  • id
  • parent_id
  • name

you need nested loop.

something like:

select * table parent_id = 0; # first level select * table parent_id = ?; # subsequent levels 

normally build object in model return array children in it. function calls , returns object append previous object. watch out recursive functions though, have tendency go wrong on you!

hope helps.


Comments

Popular posts from this blog

Need help in packaging app using TideSDK on Windows -

java - Why does my date parsing return a weird date? -

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -