php - Partial replace on a modified preorder tree traversal from script -
i have mptt (modified preorder tree traversal) this:
(taken sitepoint)
my real tree has thousands of nodes , more complex structure, simplification shows problem.
until moment, every time need change tree used shell script looks this:
#!/bin/bash mysql -umyuser -pmypass database < tree.sql
and executes (tree.sql):
drop table if exists `tree`; create table `tree` ( `parent` varchar(32) default null, `title` varchar(32) collate utf8_unicode_ci not null, `lft` int(11) not null, `rgt` int(11) not null ) engine=innodb default charset=utf8 collate=utf8_unicode_ci; lock tables `tree` write; insert `tree` values (....),(....)....
(note: use shell script because there multiple instalations of same php application in multiple servers , easy/fast way update them, if required can move update php).
but now, requirements state that:
- food/meat branch exist
- food/meat subtree must preserved because users can edit contents
- other parts of tree must updated (food/fruit in case app agnostic structure).
so, given cannot execute drop table
, need retrieve branch (food/meat) , insert tree after drop table
, create table
, insert table
executed.
the question is: how retrieve branch shell? , how insert again? (note if it's not possible shell script can create 2 small php scripts, still have no idea of how branch , insert again, idea welcome)
Comments
Post a Comment