RE: [PHP-DB] Deleting topics older than 2 hours?
| From: | John W. Holmes | Date: | Sun, 24 Nov 2002 22:49:11 +0000 |
| Subject: | RE: [PHP-DB] Deleting topics older than 2 hours? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23632@lists.php.net to get a copy of this message | ||
[snip]
> =others, eg MySQL, do not, and thus unless MySQL's last DELETE format
> option
> works sufficiently well, the best option might be two DELETE's: the
first
> per your suggestion above and the second to remove all entries in
posts
> that
> no longer join to a topics row.
But you can't join on a DELETE, either (in MySQL at least). So you're
left with writing a whole PHP script to do it. Run a SELECT to get all
of the topics with IDs older than two hours. Roll up all of those IDs
into a comma separated list, like (1,2,3,4) etc. Then run two DELETE
queries on each table.
DELETE FROM topics WHERE id IN $id_string
DELETE FROM posts WHERE topic IN $id_string
Is there a better way to organize your data so this is all in one
table?? Maybe just add another column to say whether the "message" is a
topic or a post? Then your deletes could be done with single query,
probably.
---John Holmes...