Seite 2 von 2

Verfasst: 18.08.2007 06:46
von mgutt
liegt daran, dass in der Tabelle phpbb_topics nicht die Spalten vorkommen, die du da abfragst.

schau dir mal die Tabelle mal an:
http://www.phpbb.de/doku/doku2.php?mode=topics#topics

Verfasst: 18.08.2007 12:03
von Dude23
Ok..das heißt für mich, dass ich entweder:

- irgendwie versuchen muss auch phpbb_posts anzusprechen und das da einzubauen

- oder aufgeben muss.

:-)

Also zumindest die doppelte Abfrage hab ich jetz soweit:

Code: Alles auswählen

$sql = 'SELECT * FROM phpbb_topics, phpbb_posts ORDER BY topic_time, post_time DESC LIMIT 0,5';


Jetzt bekomme ich "eigentlich" die richtige Zeit. Jedoch den falschen Topicnamen. Zudem müsste ich noch irgendwie ein DISTINCT bzw GROUP BY einbauen, weil ja die gleichen Threads nicht zweimal angezeigt werden sollen, sondern - wenn mehrere der letzten 5 Posts innerhalb eines einzigen Threads sind - gleich zum nächsten Thread gesprungen werden soll.

Verfasst: 18.08.2007 12:23
von Seimon
Ich hab sowas schon mal gecoded/zusammengestöpselt ;)

meine abfrage sah so aus

Optionen:

Code: Alles auswählen

$topic_length = '30';	// length of topic title
$topic_limit = '7';	// limit of displayed topics
$special_forums = '1';	// specify forums ('0' = no; '1' = yes)
$forum_ids = '1,2,3,4,7,8,9,10,15,19,26,30,31,32,33,34,39,41,42,43,44,46,47,48,49,53,54,55,59,61,62,63,64,65,66,67,68';		// IDs of forums; separate them with a comma
Abfrage:

Code: Alles auswählen

$where_forums = ( $special_forums == '0' ) ? '' : 't.forum_id IN ('. $forum_ids .') AND ';
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time
	FROM ". $table_prefix ."topics t, ". $table_prefix ."forums f, ". $table_prefix ."users u, ". $table_prefix ."posts p, ". $table_prefix ."posts p2, ". $table_prefix ."users u2
	WHERE $where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id".$querytoadd."
	ORDER BY t.topic_last_post_id DESC LIMIT $topic_limit";

$result = mysql_query($sql);


if( !$result )
{
	die('SQL Statement Error: '. mysql_error());
	exit();
}

vielleicht hilfts ;)

Verfasst: 18.08.2007 12:32
von Dude23
Oh Gott!

Ich nehme an, ich hab deutlich übernommen :)

Verfasst: 18.08.2007 12:42
von Seimon
Ich hab mit dem mod angefangen:

http://www.phpbb.de/moddb/phpbb_fetch_all

und mir dann herausgesucht was ich brauche

Verfasst: 18.08.2007 14:08
von Dude23
Da wäre es natürlich einfacher, wenn man von diesem Portal einfach die Tabelle mit den letzten Themen per include() einbinden könnte, aber wenn man die entsprechende Datei holt erhält man nur "hacking attempt"...

Verfasst: 19.08.2007 13:23
von Dude23
Mit folgender Abfrage klappt es:

Code: Alles auswählen

$sql = 'SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username'
        . ' FROM phpbb_topics t, phpbb_forums f, phpbb_posts p, phpbb_users u'
        . ' WHERE t.topic_id = p.topic_id AND '
        . ' f.forum_id = t.forum_id AND '
        . ' t.topic_status <> 2 AND '
        . ' p.post_id = t.topic_last_post_id AND '
        . ' p.poster_id = u.user_id'
        . ' ORDER BY p.post_id DESC LIMIT 5';