![]() |
|< 1 2 3 >| | ![]() |
23 Einträge, 3 Seiten |
Hagen+2008-04-29 12:43:49--Habe das ganze jetzt noch mal mehrmals mit Joins ausprobiert. Aber entweder ich habe den falschen Ansatz gewählt ... oder es gibt keinen Unterschied. Jedenfalls sind die Ergebnisse von 'Explain' immer die gleichen ... oder ich habe die sinnvolle Anwendung von joins nicht anwenden können.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
sub erzeuge_rss_feed { ### ggf. Beschreibung anpassen ### if ($board_id || $thread_id) { my $sql; if ($thread_id) { $sql = "SELECT title FROM $PBoard::Config::DbTables{threads} WHERE id = '$thread_id' LIMIT 1"; } # if if ($board_id) { $sql = "SELECT name FROM $PBoard::Config::DbTables{boards} WHERE id = '$board_id' LIMIT 1"; } # if my $storage = PBoard::Storage->new( { dbh => undef } ); my $poard = PBoard->new( { cgi => $cgi, storage => $storage } ); my $dbh = PBoard::DB::ConnectToDB( $poard ); $storage->set_dbh( $dbh ); my $sth = &PBoard::DB::FireSql( $poard, $sql ); (my $titel) = $sth->fetchrow_array(); $rss_board_titel .= ' :: '.$titel; } # if ### SQL ### my $sql = "SELECT boards.id as board_id, threads.id as thread_id, messages.position as position, boards.name as board_name, threads.title as thread_title, messages.message_raw as message_raw"; $sql .= "\n" if $debug; $sql .= " FROM $PBoard::Config::DbTables{boards} AS boards"; $sql .= " INNER JOIN $PBoard::Config::DbTables{threads} AS threads ON (boards.id = threads.boardID)"; $sql .= " INNER JOIN $PBoard::Config::DbTables{messages} AS messages ON (threads.id = messages.thread)"; $sql .= "\n" if $debug; $sql .= " WHERE messages.status != 'deleted' AND threads.status != 'onhold' AND threads.status != 'deleted'"; $sql .= " AND boards.groupRequired <= 2"; # nur öffentliche Boards $sql .= " AND boards.id = ?" if $board_id; $sql .= " AND threads.id = ?" if $thread_id; $sql .= " AND messages.authorId = ?" if $user_id; $sql .= " AND ((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(messages.posttime)) <= (? * 24 * 60 * 60))" if lc($action) eq lc('lastMessagesDays'); $sql .= " AND messages.position = '1'" if lc($filter) eq lc('no_replies'); $sql .= "\n" if $debug; $sql .= " ORDER BY messages.posttime DESC"; $sql .= "\n" if $debug; $sql .= " LIMIT ?"; my @placeholders; push @placeholders, $board_id if $board_id; push @placeholders, $thread_id if $thread_id; push @placeholders, $user_id if $user_id; push @placeholders, $last_entries if lc($action) eq lc('lastMessagesDays'); if (lc($action) eq lc('lastMessagesDays')) { push @placeholders, $max_entries; } # if elsif (lc($action) eq lc('lastMessagesNumbers')) { push @placeholders, $last_entries; } # if else { push @placeholders, $max_entries; } # ifelse if ($debug) { print "\n\n$sql\n\n"; foreach my $item (@placeholders) { print "- Wert(Platzhalter) ->".$item."\n"; } # foreach } # if ### DB ### my $storage = PBoard::Storage->new( { dbh => undef } ); my $poard = PBoard->new( { cgi => $cgi, storage => $storage } ); my $dbh = PBoard::DB::ConnectToDB( $poard ); $storage->set_dbh( $dbh ); my $sth = &PBoard::DB::FireSql( $poard, $sql, @placeholders ); ### Feed erzeugen ### my $rss = new XML::RSS (version => '2.0'); $rss->channel(title => $rss_board_titel, link => $rss_board_link, language => $rss_language, description => $rss_description, copyright => $rss_copyright, docs => $rss_docs, managingEditor => $rss_managingEditor, webMaster => $rss_webMaster, ); my %hash_ref; while(my $hash_ref = $sth->fetchrow_hashref) { my $link = $rss_board_link.'/thread/'.${$hash_ref}{'thread_id'}.'/startWithMessage='.(int(${$hash_ref}{'position'}/10)*10).'/#MSG'.${$hash_ref}{'position'}; $rss->add_item( title => ${$hash_ref}{'thread_title'}, link => $link, description => ${$hash_ref}{'message_raw'}, ); } # while $sth->finish; return $rss->as_string; } # sub erzeuge_rss_feed
![]() |
|< 1 2 3 >| | ![]() |
23 Einträge, 3 Seiten |