I'm having certain trouble to figure how I can receive a set of ids or the complete node info and use that data to insert the correspondent row into the db.
Why is this happening? Well, I have the following hierarchy projeto>uc>ambiente>secao>med. In my JS tree I'm using lazy loading so let's say the user select a 'projeto' and them submits all I got is the 'projeto' id, so that's easy and I know that I have to insert on the db all it's childs and their childs. But let's say the user select a particular 'ambiente' or a specific 'secao' all I get is a single id or a single node data, but to insert that info I need to insert all it's parents data before I can insert it on the db.
example 1 single 'projeto' selected data.
[{"id":"projeto_1","text":"Pr\u00e9dios P\u00fablicos","icon":"fa fa-folder icon-lg icon-state-info","parent":"#","parents":["#"],"data":{"id_mobile":"1"},"state":{"loaded":"false","opened":"false","selected":"true","disabled":"false"},"li_attr":{"id":"projeto_1"},"a_attr":{"href":"#"},"original":{"id":"projeto_1","text":"Pr\u00e9dios P\u00fablicos","icon":"fa fa-folder icon-lg icon-state-info"}}]
example 2 single 'ambiente' selected, may have 'secao' childs or not.
[{"id":"ambiente_4","text":"protocolo","icon":"fa fa-folder icon-lg icon-state-info","parent":"uc_1","parents":["uc_1","projeto_1","#"],"data":{"id_ambiente_mobile":"4"},"state":{"loaded":"false","opened":"false","selected":"true","disabled":"false"},"li_attr":{"id":"ambiente_4"},"a_attr":{"href":"#"},"original":{"id":"ambiente_4","text":"protocolo","icon":"fa fa-folder icon-lg icon-state-info","type":"ambiente"}}]
example 3 single 'secao' selected data.
[{"id":"secao_5","text":"1 Lumin\u00e1ria(s) LFT 1X40W","icon":"fa fa-folder icon-lg icon-state-info","parent":"ambiente_5","parents":["ambiente_5","uc_1","projeto_1","#"],"data":{"id_secao_mobile":"5"},"state":{"loaded":"false","opened":"false","selected":"true","disabled":"false"},"li_attr":{"id":"secao_5"},"a_attr":{"href":"#"},"original":{"id":"secao_5","text":"1 Lumin\u00e1ria(s) LFT 1X40W","icon":"fa fa-folder icon-lg icon-state-info","type":"secao"}},{"id":"ambiente_5","text":"Recep\u00e7\u00e3o","icon":"fa fa-folder icon-lg icon-state-info","parent":"uc_1","parents":["uc_1","projeto_1","#"],"children":["secao_5"],"children_d":["secao_5"],"data":{"id_ambiente_mobile":"5"},"state":{"loaded":"true","opened":"true","selected":"true","disabled":"false","loading":"false"},"li_attr":{"id":"ambiente_5"},"a_attr":{"href":"#"},"original":{"id":"ambiente_5","text":"Recep\u00e7\u00e3o","icon":"fa fa-folder icon-lg icon-state-info","type":"ambiente"}}]
all the data above is the data passed to the php file. so I just jso_encoded and posted it here.
So what I need is to insert the selected nodes in a db, but considering that if the parent node is not loaded on the tree it may have childs. And off course a solution for the case when I select a child and need to iterate all backup them insert it parent dependents before insert the child (last two examples).
Hope you guys can help me. If any clarification is needed just ask for.
Thank you.