Thread Nested Set :: Ausgabe aller Datensätze
(10 answers)
Opened by MartinR at 2010-07-02 11:56
funktioniert bei mir prima, du musst natürlich ein paar kleine anpassungen vornehmen.
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 my $sth = $dbh->prepare(<<'EOM'); SELECT n.id, n.name, count(*) -1 AS level FROM foo AS n, foo AS p WHERE n.links BETWEEN p.links AND p.rechts GROUP BY n.links ORDER BY n.links EOM $sth->execute; my @levels; while (my $row = $sth->fetchrow_hashref) { my $level = $row->{level}; $levels[$level] = $row->{name}; local $" = " > "; my @ausgabe = (@levels[0 .. $level]); print "@ausgabe\n"; } edit: @ausgabe vereinfacht Last edited: 2010-07-02 12:33:57 +0200 (CEST) Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wie frage ich & perlintro brian's Leitfaden für jedes Perl-Problem |