Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Arguile's scratchpad

by Arguile (Hermit)
on Jun 04, 2004 at 18:05 UTC ( #361038=scratchpad: print w/replies, xml ) Need Help??

In response to your retitling nodes and all replies, I thought I'd try flexing my pmdev muscles for the first time. :)

It's a quick untested hack, but should work with only a few minor modifications; thing like how to get form vars in pm, where it should go, if it's even valid.... You know, little stuff like that <g>.

Hope it helps.

# Bredth first listing of all nodes under given root (incl. root). # my $get_children = sub { my $parents = \@_; # Hackery. We should really only accept one id. my @children; my $dbh = $DB->getDatabaseHandle; local $" = ','; while ( @$parents > 0 ) { push @children, @$parents; $parents = $dbh->selectcol_arrayref(qq{ SELECT note_id FROM note WHERE parent_node IN ( @$parents ) }); } return @children; # Returns root at head of list (easier later ;) } # Runs a search and replace on the title of selected nodes. Returns # number of records updated (0 still true). # my $retitle = sub { my $new_title = shift; my $old_title = shift; my @nodes = @_; my $dbh = $DB->getDatabaseHandle; local $" = ','; $dbh->do(qq{ UPDATE note SET title = REPLACE(title, ? , ?) WHERE note_id IN( @nodes ) }, undef, ($old_title, $new_title) ); } my $id = getId($NODE); $retitle_nodes->( 'new_title_var_goes_here', getNodeById($id)->{title} +, $get_children->($id) );

P.S. While I doubt a query-per-node tree traversal (ala list replies) would be faster here -- even with the fact it's prepared -- I can change it if you'd like.


Advanced Sorting - GRT - Guttman Rosler Transform
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
erix if it weren't for bad luck, I'd have no luck at all
Discipulus Windiows the OS of native americans..
[karlgoethebier]: marioroy: Next step: Write the ultimate book. "Parallel Programming With Perl. Yet Another Missing Manual" ;-)
[marioroy]: karlgoethebier I do not do Racket ball anymore. That was from gym class long ago.
[karlgoethebier]: marioroy ;Men need a challenge
Lady_Aleena remembers winning dodgeball and wonders why parents who played it will not let their kids play it.
[marioroy]: Disciplus My wife and I went on vacation. At work, I was stuck polling SNMP from 20 million devices. It would hang at 80,000. On the mist boat, hear a voice to enable grace in the design that 10x and more performance awaits.
[Lady_Aleena]: Women need challenges too karlgoethebier. 8)
[marioroy]: s/hear/heard/
[karlgoethebier]: Discipulus: No. See https://en. wikipedia.org/ wiki/Tribe_( Native_American)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-05-29 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?