1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
sub set_unread{ my $threadID = shift; my $sth = $dbh->prepare(q{SELECT account_id FROM forum_accounts}); $sth->execute(); my @erg; while (my $zeile = $sth->fetchrow_hashref()){ push(@erg,$zeile); } $sth->finish; foreach(@erg){ unless( $_->{account_id} == $main::acc_ID){ $sth = $dbh->prepare(q{ CALL insert_forum_unread(?,?)}); $sth->execute($_->{account_id}, $threadID); $sth->finish; } } }
1
2
3
4
5
6
7
CREATE PROCEDURE insert_forum_unread( acc_id INT(10), t_id INT(10) )
BEGIN
IF NOT EXISTS(SELECT * FROM forum_threads_unread WHERE account_id=acc_id AND
thread_id=t_id) THEN
INSERT INTO forum_threads_unread (account_id, thread_id) VALUES (acc_id,t_id);
END IF;
END;
2011-09-12T17:23:35 GustlMhh, wenn ich so drüber nachdenke, wäre das wohl eine Lösung, dann brauche ich nur einen Tupel löschen beim Aufruf eines Themas.
QuoteDarf ich fragen wieviele Einträge deine table (user_id, thread_id, timestamp) im Moment hat?
2011-09-12T16:55:48 GustlEdit: Warum ist die codebox eigentlich auf 40em Breite begrenzt?