All pastes #81298 Raw Edit

Stuff

public text v1 · immutable
·published 2006-07-07 10:17 UTC
rendered paste body
        my $sth = $dbh->prepare ( q{
        SELECT medewerkers.voornaam, nieuws.id, nieuws.titel, nieuws.bericht, nieuws.aanmaakdatum
        FROM medewerkers
        RIGHT JOIN nieuws ON medewerkers.id = nieuws.medewerker_id
        });
        $sth->execute() or die "$dbh->errstr\n";

        if ($sth->rows >= 1 ) {

           my %nieuws;
           while( my ($voornaam, $id, $titel, $bericht, $datum) = $sth->fetchrow_array) {
                  map { s/\n/\<br \/\>\n/g } $bericht;
                  $nieuws{$id} = [ "$voornaam",
                                   "$titel",
                                   "$bericht",
                                   "$datum",
                                 ];
           }

           my @loop;
           foreach my $nieuws_id (sort keys %nieuws) {
                   my ($voornaam, $titel, $bericht, $datum) = @{ $nieuws{$nieuws_id}};

                   my %nieuwsbericht = (
                           voornaam  => "$voornaam",
                           titel     => "$titel",
                           bericht   => "$bericht",
                           datum     => "$datum",
                   );

                   unshift(@loop, \%nieuwsbericht);
           }