frogwarrior — 2014-01-21T06:00:03-05:00 — #1
I started a tree structure database from scratch, and I thought I had it right, heres what it looks like:
but there musta been a glitch in there somewhere because the categories aren't organised properly anymore. I don't know how to go about fixing this now. Also, I have other category tables which I'd like to convert into a heirarchical structure, but they are packed full of entries so building it up from scratch manually isn't an option. Its the lft and rgt part that would be too difficult for me to enter manually, I can put in parent ids though, and I know that I could make a script to organise the lft, rgt values based on the parent_id but don't wanna go reinventing the wheel here, is there a tool that'll do this automatically? How do you all deal with heirarchical databases? Is the left and right value approach the best way to do it?
r937 — 2014-01-21T07:54:04-05:00 — #2
with the adjacency model, as in Categories and Subcategories -- works fine up to 15 levels deep
yes, if you truly have ~unlimited~ levels of depth in your hierarchy
frogwarrior — 2014-01-21T12:37:57-05:00 — #3
I sorted it out with cakephp. It makes it pretty easy, it does all the reorganising for you when you insert or edit a row.
frogwarrior — 2014-01-23T01:32:12-05:00 — #4
CakePHP makes it real easy to convert an adjacency model database to a nested one. You just feed the parent_id into cakes Save function and it puts in the right and left values for you. I just converted a huge adjacency model database to nested model with cake.
dr_john — 2014-01-31T15:43:17-05:00 — #5
NMR Spectroscopy on a sitepoint page!
I thought I'd never see that happen.
My life is now complete and has come full circle!